Question: Is it possible to run JUnit tests located in one Gradle project, with dependencies from another project?
Background
Consider this multi-project setup:
product_1_configuration_with_tests/
feature_a_with_tests/
feature_b_with_tests/
common_integration_tests/
- For the sake of simplicity, the product project depends on the other three projects. No other dependencies exist.
common_integration_tests
contains integration tests common for all products, that must be run in the context (classpath/dependencies) of the product.common_integration_tests
can not have any dependencies to any other projects.- The behavior of the common integration tests differ depending on what is on the runtime classpath.
How can such common integration tests be run?
Attempts
Ideally I'd like the test task to be defined in the product project. I have tried including the integration test in the suite:
// In product_1_configuration_with_tests/build.gradle
task integrationTest(type: Test) {
include '**/MyIntegrationTest.class'
}
Since the test task does not find the test which resides in another module, no tests are executed.