The current Grails build script only runs tests where the class name ends in "Tests". See ant/build/unit-test.xml.
<include name="**/${test}Tests.class" />
The build excludes the several tests whose class name ends in "Test". The attached patch corrects that issue, first by updating ant/build/unit-test.xml.
<include name="**/${test}Test.class" />
<include name="**/${test}Tests.class" />
Also, Grails currently includes some classes that are not technically tests, but they still end in "Test". For example, test/persistence/org/codehaus/groovy/grails/domain/ManyToManyTest.groovy is a sample domain class used to support other test cases. This class has no test cases of its own. This patch renames that class to SampleManyToMany.groovy. Doing so prevents JUnit from looking for tests in that class (since it's not even intended to include test cases). Without that change, JUnit will expect the class to include at least one test, and it will report an error otherwise.
Grails currently includes a handful of these "sample" classes that needed to be renamed. This patch renames those classes accordingly.
–
The patch improves the Grails build by:
- Ensuring that all test cases are run with every build!
- Improving the code coverage (since the missing tests are now part of the build).
Regarding code coverage, here's a quick example of how these missing tests were resulting in inaccurate code coverage.
Look at #getFormatFromURI in the latest Grails build
. Observe that it lacks proper coverage. However, if you look at #testGetFormatFromURI in WebUtilsTest.groovy
, you can see that it provides the missing coverage. Because the current Grails build excludes this test, the coverage report wrongly reports this line as lacking coverage. This patch corrects that problem and many similar problems.