Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Possibilities of things that might be wrong with your setup:</strong></p> <ul> <li><p>Your command order is incorrect. What works for me is:</p> <p><code>grails test-app -unit Foo</code> (where my test class is <code>FooTests.groovy</code>)</p></li> <li><p>You aren't explicitly importing <code>grails.test.GrailsUnitTestCase</code>.</p> <p>I had some problems with it recognizing my tests when I didn't import this. When I was extending <code>GroovyTestCase</code>, things seemed to work normally.</p></li> </ul> <h2>Working Example</h2> <p>Here's a sample set of tests that work for me. Perhaps you can spot some differences between them and your tests?</p> <p><em>Note: These are all run with the <code>testing</code> plugin installed</em></p> <p><strong>test/unit/FooTests.groovy</strong></p> <pre><code>import grails.test.GrailsUnitTestCase class FooTest extends GrailsUnitTestCase { void testFoo() { assert true } void testBar() { assert true } } </code></pre> <p><strong>test/unit/BarTests.groovy</strong></p> <pre><code>import grails.test.GrailsUnitTestCase class BarTest extends GrailsUnitTestCase { void testFoo() { assert true } void testBar() { assert true } } </code></pre> <p><strong>test/unit/my/pkg/BazTests.groovy</strong></p> <pre><code>package my.pkg import grails.test.GrailsUnitTestCase class BazTest extends GrailsUnitTestCase { void testFoo() { assert true } void testBar() { assert true } } </code></pre> <p><strong>command: all unit tests</strong></p> <pre><code>$ grails test-app -unit ... Starting unit test phase ... ------------------------------------------------------- Running 6 unit tests... Running test my.pkg.BazTest...PASSED Running test FooTest...PASSED Running test BarTest...PASSED Tests Completed in 847ms ... ------------------------------------------------------- Tests passed: 6 Tests failed: 0 ------------------------------------------------------- ... Tests PASSED - view reports in target/test-reports </code></pre> <p><strong>command: Foo unit tests</strong></p> <pre><code>$ grails test-app -unit Foo ... Starting unit test phase ... ------------------------------------------------------- Running 1 unit test... Running test FooTest...PASSED Tests Completed in 815ms ... ------------------------------------------------------- Tests passed: 2 Tests failed: 0 ------------------------------------------------------- ... Tests PASSED - view reports in target/test-reports </code></pre> <p><strong>command: my.pkg.Baz unit tests</strong></p> <pre><code>$ grails test-app -unit my.pkg.Baz ... Starting unit test phase ... ------------------------------------------------------- Running 2 unit tests... Running test my.pkg.BazTest...PASSED Tests Completed in 842ms ... ------------------------------------------------------- Tests passed: 2 Tests failed: 0 ------------------------------------------------------- ... Tests PASSED - view reports in target/test-reports </code></pre> <p><em>I tried these in Grails 1.2.3 and Grails 1.3.4, both behaved the same.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload