JBT
JBT

Reputation: 8746

grails 2.3: tests not recognized by test-app

I am playing with the recently released grails 2.3.0. Unfortunately, test-app is not recognizing tests. Here is what I did to produce the problem.

First, make a new app and create a controller:

$ grails create-app firstApp
$ cd firstApp/
$ grails create-controller foo

I got the following files from creating the controller foo:

| Created file grails-app/controllers/firstapp/FooController.groovy
| Created file grails-app/views/foo
| Created file test/unit/firstapp/FooControllerSpec.groovy

Then, I edited the file FooControllerSpec.groovy by adding assert 1 == 2 in the auto-generated method void "test something"(). Here is the full content of FooControllerSpec.groovy after my editing:

package firstapp

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
@TestFor(FooController)
class FooControllerSpec extends Specification {

    def setup() {
    }

    def cleanup() {
    }

    void "test something"() {
        assert 1 == 2
    }
}

Then I ran the following command:

$ grails test-app

However, no tests were run. Here is the output from that command:

| Completed 0 unit test, 0 failed in 0m 0s
| Tests PASSED - view reports in /Users/jianbao.tao/projects/grails/firstApp/target/test-reports

My platform is OS X 10.8.5 + grails 2.3.0 + Java 1.6.0_51 + groovy 2.1.6. Can anyone tell me what's going on here, please? Thank you in advance.

Upvotes: 3

Views: 1264

Answers (1)

dmahapatro
dmahapatro

Reputation: 50245

Grails 2.3.0 ships with spock test framework by default. So, the test should look like:

void "test something"() {
    expect:
      1 == 2
}

For details on spockframework, visit docs.

Upvotes: 8

Related Questions