void () { String srcRoot = PathUtil.getParentPath(createFile("src/A.java", "public class A { ATest test;}")); String testRoot = PathUtil.getParentPath(createFile("testSrc/ATest.java", "public class ATest {}")); JpsModule m = addModule("m", srcRoot); JpsModule commonTests = addModule("common.tests", ArrayUtilRt.EMPTY_STRING_ARRAY, getAbsolutePath("out/production/common.tests"), getAbsolutePath("out/tests/common.tests"), getJdk()); commonTests.addSourceRoot(JpsPathUtil.pathToUrl(testRoot), JavaSourceRootType.TEST_SOURCE); //this dependency is actually not needed for compilation; it's added to ensure that without proper dependency from production to test targets are build in wrong order commonTests.getDependenciesList().addModuleDependency(m); JpsModuleDependency dependency = m.getDependenciesList().addModuleDependency(commonTests); JpsGradleExtensionService.getInstance().getOrCreateExtension(m, JpsGradleModuleExtension.GRADLE_SOURCE_SET_MODULE_TYPE_KEY); doBuild(CompileScopeTestBuilder.rebuild().allModules()).assertFailed(); JpsGradleExtensionService.getInstance().setProductionOnTestDependency(dependency, true); rebuildAllModules(); }