我正在使用主要sourceSet中的一组测试和代码编写一个训练任务。我还想在一个单独的sourceSet中提供一个示例答案,该源集可以使用单独的任务运行。有没有办法在两个不同的主要源集上运行相同的测试集?
答案 0 :(得分:0)
事实证明,这可以通过从运行时类路径中删除主sourceSet来实现,如下所示:
task testAnswers(type: Test) {
description = "Runs tests against the example answer"
testClassesDir = sourceSets.answers.output.classesDir
classpath -= sourceSets.main.runtimeClasspath
classpath += sourceSets.answers.runtimeClasspath
}