GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / cli / CreateUnitTestTests.groovy
blob6d0f619e65deb700d3d2d286e347263b73dbf358
1 package org.codehaus.groovy.grails.cli
3 class CreateUnitTestTests extends AbstractCliTests {
4 def appDir
6 void testCreateUnitTest() {
7 appDir = createTestApp()
9 tryUnitTest('Book')
10 tryUnitTest('org.example.Author')
11 tryUnitTest('project-item', 'ProjectItem')
14 void tryUnitTest(String className) {
15 tryUnitTest(className, className)
18 void tryUnitTest(String scriptArg, String className) {
19 // Run the create unit test script with a single argument.
20 System.setProperty("grails.cli.args", scriptArg)
21 gantRun( ["-f", "scripts/CreateUnitTest.groovy"] as String[])
23 // Extract any package from the class name.
24 def pkg = null
25 def pos = className.lastIndexOf('.')
26 if (pos != -1) {
27 pkg = className[0..<pos]
28 className = className[(pos + 1)..-1]
31 def pkgPath = ''
32 if (pkg) {
33 pkgPath = pkg.replace('.' as char, '/' as char) + '/'
36 // Check that the unit test has been created.
37 // Now check that the associated test has also been created.
38 def testFile = new File("${appDir}/test/unit/${pkgPath}${className}Tests.groovy")
39 assert testFile.exists()
40 assert testFile.text =~ "^${pkg ? 'package ' + pkg : ''}\\s*class ${className}Tests extends GroovyTestCase \\{"