Question

I'm trying to make my tasks run tests in a certain directory. I was looking at sourceSets, however I inferred that they are useful if you are running outside the test/groovy folder. All of my tests are within the test/groovy folder.

I've got a set of Geb tests as well as a set of service tests. I would like to run them both together and independently. Essentially my tree structure would look like this, being able to run all tests.

Test
--gebTest
----firefoxTest
----chromeTest
----ieTest
--servicesTest
----service1Test
----service2Test
----service3Test
----etc.

My file structure is as follows:

project
-src
--test
---groovy
----com
-----acme
------functional <---where my geb tests sit
------services <---umbrella for services
-------service1 <---each unique service
-------service2
-------service3
-------etc

Can anyone lend me a hand. For the life of me I don't know how Gradle picks what tests to execute.

Thank you in advanced.

Was it helpful?

Solution

SourceSets are indeed a solution to your problem, but I notice you only differentiate your tests by their package names. I'm not sure but that may prove problematic with source sets.

Personally I would prefer a directory structure like this anyway

src
-test
--groovy
---functional
----com etc
---services
----com etc

However, if you are attached to your current structure then take a look at Gradle's test filtering support, which will allow you to filter by package name.

http://www.gradle.org/docs/current/userguide/java_plugin.html#sec:java_test

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top