Grails Unit Test Exception java.lang.Exception: No tests found matching grails test target pattern filter -
i starting learn grails testing , tried write first grails test.for this, created fresh grails project , created controller named com.rahulserver.somecontroller:
package com.rahulserver class somecontroller { def index() { } def someaction(){ } } when created controller, grails automatically created com.rahulserver.somecontrollerspec under test/unit folder. here somecontrollerspec.groovy:
package com.rahulserver import grails.test.mixin.testfor import spock.lang.specification /** * see api {@link grails.test.mixin.web.controllerunittestmixin} usage instructions */ @testfor(somecontroller) class somecontrollerspec extends specification { def setup() { } def cleanup() { } void testsomeaction() { assert 1==1 } } when right click class, , run test, following:
testing started @ 5:21 pm ... |loading grails 2.4.3 |configuring classpath . |environment set test .................................... |running without daemon... .......................................... |compiling 1 source files . |running 1 unit test...|running 1 unit test... 1 of 1 --output initializationerror-- failure: | initializationerror(org.junit.runner.manipulation.filter) | java.lang.exception: no tests found matching grails test target pattern filter org.junit.runner.request$1@1f0f9da5 @ org.junit.internal.requests.filterrequest.getrunner(filterrequest.java:35) @ org.junit.runner.junitcore.run(junitcore.java:138) no tests found matching grails test target pattern filter org.junit.runner.request$1@1f0f9da5 java.lang.exception: no tests found matching grails test target pattern filter org.junit.runner.request$1@1f0f9da5 @ org.junit.internal.requests.filterrequest.getrunner(filterrequest.java:35) @ org.junit.runner.junitcore.run(junitcore.java:138) |completed 1 unit test, 1 failed in 0m 0s .tests failed | - view reports in d:\115labs\grailsunittestdemo\target\test-reports error | forked grails vm exited error process finished exit code 1 so why failing?
edit
i using grails 2.4.3
the unit tests defined spock default:
void testsomeaction() { assert 1==1 } should written as:
void "test action"() { expect: 1==1 } see http://spockframework.github.io/spock/docs/1.0/index.html
Comments
Post a Comment