How to include/exclude test cases when running a test task?


(uyentvu) #1

All,

I am running gradle-1.0-milestone-3.

I defined a task called ‘runTests’ of type ‘Test’. I would like to use include and exclude certain test cases when I run this task.

Below is my code but does not seem to work: task runTests(type: Test) << {

// Is this how to include individual test case? which option below is correct?

include ‘RunAllIntegrationTests.class’

//option 1

include ‘**/RunAllIntegrationTests.class’ //option 2

// Is this how to exclude all test cases under a specific directory?

exclude ‘com/abc/test/windowtester/**’

exclude ‘com/abc/def/myfolder/windowtester/**’

//Is this how to exclude a specific test case? which option below is correct?

exclude ‘TestAppLauncherAutoTest.class’

//option1

exclude ‘**/TestAppLauncherAutoTest.class’ //option2

}

Any help or insight would be greatly appreciated.

Thanks.


(Peter Niederwieser) #2

Option 2 is correct. Without more information, I can’t say what the problem is. Make sure that your includes/excludes matches the directory structure under build/classes/test.


(uyentvu) #3

When I defined the test task like below (no ‘<<’ in front of the open bracket), then it works:

task runTests(type: Test) {

include ‘com/abc/test/windowtester/**AutoTest.*’

//include any class that ends with “AutoTest” include ‘**/RunAllIntegrationTests.class’

//include one specific test class exclude ‘**/TestAppLauncherAutoTest.class’

//exclude one specific test class }

Thanks for your response.


(uyentvu) #4

Please ignore my previous reply. Some how when I click ‘Reply’ button, the format of my message was messed up and I lost some of my message contents.

What I was trying to say was when I removed the “<<” before the open bracket when defining the test task, then it seems to work. Please look at my code in the image attached.


(uyentvu) #5

Peter,

I was trying to upload an image to show my code but I could not do it successfully. Just want to let you know that it works for me now.

Thanks for your help.