Details
Description
I have the following controller classes
class MyController {
def index = { }
def list = {
withFormat{
json{
render(contentType:"text/json"){
success(true)
}
}
}
}
def info = {
withFormat{
json{
render(contentType:"text/json"){ success(true) } }
}
}
}
}
with the following integration test
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
}
}
now if you run
grails test-app -integration you get
Running tests of type 'integration'
-------------------------------------------------------
Running 2 integration tests...
Running test ssmithstone.MyControllerIntegrationTests...
testJSONResponseForInfo...FAILED
Tests Completed in 334ms ...
-------------------------------------------------------
Tests passed: 1
Tests failed: 1
-------------------------------------------------------
however if you run
grails test-app -integration ssmithstone.MyControllerIntegration.testJSONResponseForInfo
Starting integration tests ...
Running tests of type 'integration'
-------------------------------------------------------
Running 1 integration test...
Running test ssmithstone.MyControllerIntegrationTests...PASSED
Tests Completed in 245ms ...
-------------------------------------------------------
Tests passed: 1
Tests failed: 0
-------------------------------------------------------
so there is a bug there somewhere.
Attachments
Issue Links
| This issue is duplicated by: | ||||
| GRAILS-5685 | ConfigurationHelper.config null in integration tests (was GRAILS-4780) |
|
|
|
| This issue is related to: | ||||
| GRAILS-5071 | ApplicationTagLib.makeServerURL fails if config is null (and some related issues...) |
|
|
|
| GRAILS-5757 | create-integration-test creates a subclass of GrailsUnitTestCase |
|
|
|
This is not a issue. Please extend GroovyTestCase for your integration tests.