4

I have an android project with unit and integration tests in the same folder. If I run ./gradlew test all of them are run, but I just need to exclude the cucumber tests from running, at the moment I just need to actually exclude to run the class with the annotation @RunWith(Cucumber.class).

Any suggestions?

tir38
  • 9,810
  • 10
  • 64
  • 107
Shilaghae
  • 957
  • 12
  • 22
  • Cucumber is not standard install in gradle. Are you calling jar or using gradle-cucumber plugin? Both have options for filtering by tag. https://github.com/samueltbrown/gradle-cucumber-plugin – drkstr101 Jun 15 '17 at 15:42
  • when you say unit and integration tests in same folder, do you mean local (run on your machine) and instrumented (run on a device) tests in the same folder? – tir38 Feb 05 '20 at 23:58

1 Answers1

3

The usual way of adding a test closure like below does not work for some reason with gradle android plugin:

test {
  exclude 'com/example/MyTest.*'

}

Instead I have found the following option. Use the @Ignore annotation on your test(s). You can also conditionally ignore the test (e.g. based on a system property like RUN_AUTOMATION_TEST=false) using this answer

If you are using spock rather than junit then use something like this:

@IgnoreIf( {System.getProperty('RUN_AUTOMATION_TESTS') == null} )
public class MainScreenSpec extends BaseUiAutomationSpec {
}
Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54