Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.1-RC1
-
Component/s: Project infrastructure
-
Labels:None
Description
Current TestApp script executes the whole TestSuite/TestCase. many a times we would only want to run a particular test method. So it would be helpful if we can run individual test method like
>grails test-app TestClass.testMethod
The above command should only execute the testMethod and not the entire testcase of TestClass.
Issue Links
- relates to
-
GRAILS-2293
integration test total reported incorrectly
-
To accomplish this I have modified the TestApp script from Grails distribution. It is attached as TestApp2.groovy. The approach taken by me is sort of hacky and not that clean. To execute the individual testMethods I added
class GrailsMethodTestSuite extends GrailsTestSuite {
{ super(applicationContext,clazz) this.methodNames = methods this.clazz = clazz addTestMethods() }private def methodNames
private def clazz
public GrailsMethodTestSuite(applicationContext,clazz,methods)
public void addTest(Test test)
{ //eat up the test methods which are added during initialization in //TestSuite constructor }def addTestMethods(){
{ super.addTest(test) }TestSuite ts = new TestSuite(clazz) //create a testsuite so as to get testnames
for (Enumeration e= ts.tests(); e.hasMoreElements(); ) {
def test= e.nextElement();
if(this.methodNames.contains(test.name))
}
}
}
In the script only and modified few parts so as to use GrailsMethodTestSuite if any test method is specified . By default the script uses GrailsTestSuite if no method is specified. The above suite would eat up any test methods added during testsuite initialization and later adds the one we are interested in.