1

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.

TIMBERings
  • 361
  • 1
  • 4
  • 17
  • Not sure I completely understand, when you run `gradle test`, it executes using `JUNIT` all the methods in classes that have `@Test` annotation. Each class runs independently. http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html , JUNIT example - http://www.vogella.com/tutorials/JUnit/article.html – First Zero Jan 31 '14 at 02:55
  • The problem is that it runs ALL of my tests. I want to be able to run a task that does functional tests, then another task to run the services tests. – TIMBERings Jan 31 '14 at 15:26
  • :) In which case you are looking for this answer - http://stackoverflow.com/questions/9606904/how-to-run-junit-testsuites-from-gradle – First Zero Jan 31 '14 at 15:31

1 Answers1

1

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

Perryn Fowler
  • 2,192
  • 1
  • 12
  • 20