/** * Returns the test class files. * * <p>This is the special case we need to handle - if getCandidateClassFiles is called * too early, i.e. before the task is fully configured, return an empty FileTree. The * default is to create a FileTree using getTestClassesDir(), but that creates a * FileTree with a null root, which fails later on. * * @see ConfigAction#configureSources(AndroidUnitTest) */ @Override public FileTree getCandidateClassFiles() { if (getTestClassesDir() == null) { return getProject().files().getAsFileTree(); } else { return super.getCandidateClassFiles(); } }
private List<String> collectTestNames(Test testTask) { ClassNameCollectingProcessor processor = new ClassNameCollectingProcessor(); Runnable detector; final FileTree testClassFiles = testTask.getCandidateClassFiles(); if (testTask.isScanForTestClasses()) { TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector(); testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir()); testFrameworkDetector.setTestClasspath(testTask.getClasspath()); detector = new PluginTestClassScanner(testClassFiles, processor); } else { detector = new PluginTestClassScanner(testClassFiles, processor); } final Object testTaskOperationId = OperationIdGenerator.generateId(testTask); new TestMainAction(detector, processor, new NoOpTestResultProcessor(), new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), String.format("Gradle Eclipse Test Run %s", testTask.getPath())).run(); LOGGER.info("collected test class names: {}", processor.classNames); return processor.classNames; }