tests for new project not getting found or run correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

tests for new project not getting found or run correctly

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.
| 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$1@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$1@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 "
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

burtbeckwith
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

wantsomezen wrote
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$1@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$1@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 "
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

wantsomezen
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>

On Apr 9, 2014, at 7:10 PM, burtbeckwith [via Grails] <[hidden email]> wrote:

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

wantsomezen wrote
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$1@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$1@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 "
    }
}



If you reply to this email, your message will be added to the discussion below:
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)

Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

hemelend
In reply to this post by wantsomezen
Hi I am having the same error using Grails 2.4.0. do you have any way to solve the error?

thanks;

hemelend.
Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

wantsomezen
answer above worked fine...needed to fill in some code for the test to work.
Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

hemelend
actually, i am having issues with ScriptExitException error.  cuold you let me know you did to solved that error?
Reply | Threaded
Open this post in threaded view
|

Re: tests for new project not getting found or run correctly

wantsomezen
For me, the whole problem went away when I added code into the tests.  Not sure I can help you.