tags:

views:

131

answers:

0

running with grails 1.1.1

package ssmithstone

class MyController {

  def index = { }

  def list = {
    withFormat{
      json{
        render(contentType:"text/json"){
          success(true)
        }
      }
    }
  }

  def info = {
    withFormat{
      json{
        render(contentType:"text/json"){
          success(true)
        }
      }
    }

  }
}

package ssmithstone

import grails.test.GrailsUnitTestCase

class MyControllerIntegrationTests extends GrailsUnitTestCase {
  MyController controller

  protected void setUp() {
    super.setUp()
    controller = new MyController()
  }

  protected void tearDown() {
    super.tearDown()
  }
  void testJSONResponseForList() {

    controller.request.contentType = "text/json"

    controller.list()

    String actualJSON = controller.response.contentAsString

    assertEquals "{\"success\":true}" , actualJSON
  }

  void testJSONResponseForInfo(){

    controller.request.contentType = "text/json"

    controller.info()

    String actualJSON = controller.response.contentAsString

    assertEquals "{\"success\":true}" , actualJSON

  }

}

running

grails test-app integration i get the following

Starting integration tests ...
Running tests of type 'integration'

Running 2 integration tests...
Running test ssmithstone.MyControllerIntegrationTests... testJSONResponseForInfo...FAILED
Tests Completed in 215ms ...

we can see testJSONResponseForInfo failes, however

grails test-app -integration ssmithstone.MyControllerIntegration.testJSONResponseForInfo

Running tests of type 'integration'

Running 1 integration test...
Running test ssmithstone.MyControllerIntegrationTests...PASSED
Tests Completed in 233ms ...

can any one see why running the single tests passes by running the test class fails

Cheers

I've put the project at

ssmithstone GrailsIntegrationTDD