Sign in to edit and +1 items.
Login required
Download

Testing Labs

(0)
Author(s) RobertFischer
Current Release 0.4.0   (2 years ago)
Grails Version 1.2 > *
Tags integration  testing  utility 
Dependency
compile ":testing-labs:0.4.0"
Last updated by admin 3 years ago
grails install-plugin testing-labs
Last updated by RobertFischer 2 years ago

Testing Labs

This plugin provides extensions to the Grails testing environment in order to fix bugs and make life easier.

Functionality Provided

  • Fix for GRAILS-4460
  • "create-controller-integration-test", which accepts the logical name for the controller and constructs a controller integration test in the proper package with the appropriate set of imports and the following properties.
    • "instance" - An instance of the controller under test, also accessible via the controller's logical name (e.g.: "foo.bar.BazController" is accessible as the "baz" property).
    • "request" - The mock request attached to "instance"
    • "response" - The mock response attached to "instance"
    • "session" - The mock session attached to "instance"
    • "params" - The parameter map attached to "instance"
    • "view" - The view attached to the instance's "modelAndView"
    • "viewName" - The name of the view attached to the instance's "modelAndView"
    • "model" - The model attached to the instance's "modelAndView".
    • Spring beans - The controller instance is also autowired with any Spring beans (as of 0.3.1).

Controller Integration Test Example

The Grails integration test example would look like this using "create-controller-integration-test":

class FooController {
  def text = { render "bar" }
  def someRedirect = { redirect(action:"bar") }
}

grails create-controller-integraiton-test foo

class FooControllerTests extends ControllerIntegrationTestCase {

void testText() { foo.text() assertEquals("bar", response.contentAsString) }

void testSomeRedirect() { foo.someRedirect() assertEquals("/foo/bar", response.redirectedUrl) }

Last updated by admin 3 years ago
Last updated by admin 3 years ago