Discussion:
tests for new project not getting found or run correctly
wantsomezen
2014-04-09 23:00:17 UTC
Permalink
Grails newbie trying to run through the examples. Using Grails 2.3.7 and
Groovy 2.0

run-app works fine, but for some reason. The tests are not getting run.

dump and code that I modified below.

grails> create-unit-test first
| Created file test/unit/tapp2/FirstSpec.groovy
grails> run-app
| Server running. Browse to http://localhost:8080/tApp2
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion:
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
java.lang.Exception: No tests found matching grails test target pattern
filter from org.junit.runner.Request$***@ee5d13
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
| Error Error running script test-app:
org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to see
the full trace)
grails>
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
java.lang.Exception: No tests found matching grails test target pattern
filter from org.junit.runner.Request$***@19a12ee
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
| Error Error running script test-app :
org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to see
the full trace)




package tapp2

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

/**
* See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for
usage instructions
*/



@TestFor(MyController)
class MyControllerSpec extends Specification {

def setup() {
println "sss"
}

def cleanup() {
println "ccc"
}

void "test something 222"() {
println "slkjf"
}
}


package tapp2

import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.Specification

/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for
usage instructions
*/
@TestMixin(GrailsUnitTestMixin)
class FirstSpec extends Specification {

def setup() {
println "first setup"
}

def cleanup() {
println "first cleanup"
}

void "test something"() {
println "test something "
}
}




--
View this message in context: http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
burtbeckwith
2014-04-09 23:07:27 UTC
Permalink
Spock test methods have to have at least one labelled section to be
considered test methods. You need given/when/then/etc. sections. Or you can
convert the tests to JUnit style if you prefer.

Burt
Post by wantsomezen
Grails newbie trying to run through the examples. Using Grails 2.3.7 and
Groovy 2.0
run-app works fine, but for some reason. The tests are not getting run.
dump and code that I modified below.
grails> create-unit-test first
| Created file test/unit/tapp2/FirstSpec.groovy
grails> run-app
| Server running. Browse to http://localhost:8080/tApp2
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
java.lang.Exception: No tests found matching grails test target pattern
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to
see the full trace)
grails>
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
java.lang.Exception: No tests found matching grails test target pattern
at
org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to
see the full trace)
package tapp2
import grails.test.mixin.TestFor
import spock.lang.Specification
/**
for usage instructions
*/
@TestFor(MyController)
class MyControllerSpec extends Specification {
def setup() {
println "sss"
}
def cleanup() {
println "ccc"
}
void "test something 222"() {
println "slkjf"
}
}
package tapp2
import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.Specification
/**
for usage instructions
*/
@TestMixin(GrailsUnitTestMixin)
class FirstSpec extends Specification {
def setup() {
println "first setup"
}
def cleanup() {
println "first cleanup"
}
void "test something"() {
println "test something "
}
}
--
View this message in context: http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870p4655871.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
wantsomezen
2014-04-10 10:32:21 UTC
Permalink
Thanks for the prompt reply. I added the given-when-thens and the test seemed to perform correctly. Perhaps the Grails team may want to add some default given-when-thens to the template so others don’t have the same problem. It would better match the documentation as well.

I did note that I still get a ScriptExitException. Here is the corrected test I ran and the test-app output:

package tapp2

import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.Specification

/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
@TestMixin(GrailsUnitTestMixin)
class FirstSpec extends Specification {

def setup() {
println "first setup"
}

def cleanup() {
println "first clenupup"
}

void "test something"() {
given: "test given"
println "first given"

when: "test when"
println "first when"

then: "test then"
println "first then"
}
}



grails> test-app -echoOut --stacktrace First
| Running without daemon...
................................................
|Compiling 1 source files
.
|Running 1 unit test

|Running 1 unit test... 1 of 1
--Output from test something--
first setup
first given
first when
first then
first clenupup
|Completed 1 unit test, 0 failed in 0m 1s
.................
|Tests PASSED - view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Error running script test-app -echoOut --stacktrace First: org.codehaus.groovy.grails.cli.ScriptExitException (NOTE: Stack trace has been filtered. Use --verbose to
see entire trace.)
org.codehaus.groovy.grails.cli.ScriptExitException
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:98)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at TestApp$_run_closure1.doCall(TestApp.groovy:32)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant.executeTargets(Gant.groovy:590)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
| Error Error running script test-app -echoOut --stacktrace First: org.codehaus.groovy.grails.cli.ScriptExitException
grails>
Spock test methods have to have at least one labelled section to be considered test methods. You need given/when/then/etc. sections. Or you can convert the tests to JUnit style if you prefer.
Burt
Grails newbie trying to run through the examples. Using Grails 2.3.7 and Groovy 2.0
run-app works fine, but for some reason. The tests are not getting run.
dump and code that I modified below.
grails> create-unit-test first
| Created file test/unit/tapp2/FirstSpec.groovy
grails> run-app
| Server running. Browse to http://localhost:8080/tApp2
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
| Error Error running script test-app: org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to see the full trace)
grails>
grails> test-app
| Running without daemon...
................................................
|Compiling 2 source files
.
|Running 2 unit tests...
|Running 2 unit tests... 1 of 2
Failure: |
initializationError(org.junit.runner.manipulation.Filter)
|
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:35)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
|Completed 1 unit test, 1 failed in 0m 0s
.................Tests FAILED
|
- view reports in C:\mroot\gplay\projects\tApp2\target\test-reports
| Error Forked Grails VM exited with error
| Error Error running script test-app : org.codehaus.groovy.grails.cli.ScriptExitException (Use --stacktrace to see the full trace)
package tapp2
import grails.test.mixin.TestFor
import spock.lang.Specification
/**
*/
@TestFor(MyController)
class MyControllerSpec extends Specification {
def setup() {
println "sss"
}
def cleanup() {
println "ccc"
}
void "test something 222"() {
println "slkjf"
}
}
package tapp2
import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.Specification
/**
*/
@TestMixin(GrailsUnitTestMixin)
class FirstSpec extends Specification {
def setup() {
println "first setup"
}
def cleanup() {
println "first cleanup"
}
void "test something"() {
println "test something "
}
}
http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870p4655871.html
To unsubscribe from tests for new project not getting found or run correctly, click here.
NAML
Thanks,
Ray Trask

I solve problems better when we speak.
So call me...
614-787-4123 (cell)





--
View this message in context: http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870p4655891.html
Sent from the Grails - user mailing list archive at Nabble.com.
wantsomezen
2014-05-29 19:40:24 UTC
Permalink
answer above worked fine...needed to fill in some code for the test to work.



--
View this message in context: http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870p4657043.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
wantsomezen
2014-05-30 12:47:00 UTC
Permalink
For me, the whole problem went away when I added code into the tests. Not
sure I can help you.



--
View this message in context: http://grails.1312388.n4.nabble.com/tests-for-new-project-not-getting-found-or-run-correctly-tp4655870p4657047.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Continue reading on narkive:
Loading...