Java 类org.gradle.api.tasks.testing.Test 实例源码

项目:Reer    文件:TestExecutionBuildConfigurationAction.java   
private List<Test> configureBuildForInternalJvmTestRequest(GradleInternal gradle, TestExecutionRequestAction testExecutionRequest) {
    final Collection<InternalJvmTestRequest> internalJvmTestRequests = testExecutionRequest.getInternalJvmTestRequests();
    if(internalJvmTestRequests.isEmpty()){
        return Collections.emptyList();
    }

    List<Test> tasksToExecute = new ArrayList<Test>();

    final Set<Project> allprojects = gradle.getRootProject().getAllprojects();
    for (Project project : allprojects) {
        final Collection<Test> testTasks = project.getTasks().withType(Test.class);
        for (Test testTask : testTasks) {
            for (InternalJvmTestRequest jvmTestRequest : internalJvmTestRequests) {
                final TestFilter filter = testTask.getFilter();
                filter.includeTest(jvmTestRequest.getClassName(), jvmTestRequest.getMethodName());
            }
        }
        tasksToExecute.addAll(testTasks);
    }
    return tasksToExecute;
}
项目:Reer    文件:JacocoPlugin.java   
/**
 * Adds report tasks for specific default test tasks.
 *
 * @param extension the extension describing the test task names
 */
private void addDefaultReportTasks(final JacocoPluginExtension extension) {
    project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
        @Override
        public void execute(JavaPlugin javaPlugin) {
            project.getTasks().withType(Test.class, new Action<Test>() {
                @Override
                public void execute(Test task) {
                    if (task.getName().equals(JavaPlugin.TEST_TASK_NAME)) {
                        addDefaultReportTask(extension, task);
                    }
                }
            });
        }
    });
}
项目:Reer    文件:JavaBasePlugin.java   
private void configureBasedOnSingleProperty(final Test test) {
    String singleTest = getTaskPrefixedProperty(test, "single");
    if (singleTest == null) {
        //configure inputs so that the test task is skipped when there are no source files.
        //unfortunately, this only applies when 'test.single' is *not* applied
        //We should fix this distinction, the behavior with 'test.single' or without it should be the same
        test.getInputs().files(test.getCandidateClassFiles())
            .withPropertyName("nonEmptyCandidateClassFiles")
            .withPathSensitivity(PathSensitivity.RELATIVE)
            .skipWhenEmpty();
        return;
    }
    test.prependParallelSafeAction(new Action<Task>() {
        public void execute(Task task) {
            test.getLogger().info("Running single tests with pattern: {}", test.getIncludes());
        }
    });
    test.setIncludes(WrapUtil.toSet("**/" + singleTest + "*.class"));
    test.addTestListener(new NoMatchingTestsReporter("Could not find matching test for pattern: " + singleTest));
}
项目:Reer    文件:JavaBasePlugin.java   
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
    DslObject htmlReport = new DslObject(test.getReports().getHtml());
    DslObject xmlReport = new DslObject(test.getReports().getJunitXml());

    xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), test.getName());
        }
    });
    htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestReportDir(), test.getName());
        }
    });
    test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), test.getName() + "/binary");
        }
    });
    test.workingDir(project.getProjectDir());
}
项目:ide-plugins    文件:EclipseTestExecuter.java   
private List<String> collectTestNames(Test testTask, Object testTaskOperationId, Object rootTestSuiteId) {
    ClassNameCollectingProcessor processor = new ClassNameCollectingProcessor();
    Runnable detector;
    final FileTree testClassFiles = testTask.getCandidateClassFiles();
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClasses(testTask.getTestClassesDirs().getFiles());
        testFrameworkDetector.setTestClasspath(testTask.getClasspath().getFiles());
        detector = new EclipsePluginTestClassScanner(testClassFiles, processor);
    } else {
        detector = new EclipsePluginTestClassScanner(testClassFiles, processor);
    }

    new TestMainAction(detector, processor, new NoOpTestResultProcessor(), Time.clock(), testTaskOperationId, rootTestSuiteId, String.format("Gradle Eclipse Test Run %s", testTask.getIdentityPath())).run();
    LOGGER.info("collected test class names: {}", processor.classNames);
    return processor.classNames;
}
项目:gradle-java-modules    文件:JigsawPlugin.java   
private void configureTestTask(final Project project) {
    final Test testTask = (Test) project.getTasks().findByName(JavaPlugin.TEST_TASK_NAME);
    final SourceSet test = ((SourceSetContainer) project.getProperties().get("sourceSets")).getByName("test");
    final JavaModule module = (JavaModule) project.getExtensions().getByName(EXTENSION_NAME);
    testTask.getInputs().property("moduleName", module.geName());
    testTask.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            List<String> args = new ArrayList<>();
            args.add("--module-path");
            args.add(testTask.getClasspath().getAsPath());
            args.add("--add-modules");
            args.add("ALL-MODULE-PATH");
            args.add("--add-reads");
            args.add(module.geName() + "=junit");
            args.add("--patch-module");
            args.add(module.geName() + "=" + test.getJava().getOutputDir());
            testTask.setJvmArgs(args);
            testTask.setClasspath(project.files());
        }
    });
}
项目:ekstazi-gradle-plugin    文件:EkstaziPlugin.java   
@Override
public void apply(Project project) {
    EkstaziExtension extension = project.getExtensions().create(EKSTAZI, EkstaziExtension.class);
    project.afterEvaluate(p ->
            {
                Configuration ekstazi = project.getConfigurations().detachedConfiguration(
                        new DefaultExternalModuleDependency(EKSTAZI_GROUP, EKSTAZI_NAME, extension.getVersion())
                );
                p.getTasks().withType(Test.class).forEach(task ->
                        {
                            task.dependsOn(ekstazi);
                            System.out.println( extension.toString());
                            task.jvmArgs(
                                    String.format("-javaagent:%s=root.dir=%s,%s",
                                            ekstazi.getFiles().iterator().next().getAbsolutePath(),
                                            task.getProject().getBuildDir().getAbsolutePath() + File.separator +
                                                    ".ekstazi" + File.separator + task.getName(),
                                            extension.toString())
                            );
                        }
                );
            }
    );
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
private void configureBasedOnSingleProperty(final Test test) {
    String singleTest = getTaskPrefixedProperty(test, "single");
    if (singleTest == null) {
        //configure inputs so that the test task is skipped when there are no source files.
        //unfortunately, this only applies when 'test.single' is *not* applied
        //We should fix this distinction, the behavior with 'test.single' or without it should be the same
        test.getInputs().source(test.getCandidateClassFiles());
        return;
    }
    test.doFirst(new Action<Task>() {
        public void execute(Task task) {
            test.getLogger().info("Running single tests with pattern: {}", test.getIncludes());
        }
    });
    test.setIncludes(WrapUtil.toSet(String.format("**/%s*.class", singleTest)));
    test.addTestListener(new NoMatchingTestsReporter("Could not find matching test for pattern: " + singleTest));
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
    DslObject htmlReport = new DslObject(test.getReports().getHtml());
    DslObject xmlReport = new DslObject(test.getReports().getJunitXml());

    xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestResultsDir();
        }
    });
    htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getTestReportDir();
        }
    });
    test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName()));
        }
    });
    test.workingDir(project.getProjectDir());
}
项目:graclj    文件:ClojureTestSuiteRules.java   
@BinaryTasks
public void copyGracljTools(ModelMap<Task> tasks, JUnitTestSuiteBinarySpec binary, GracljInternal internal) {
    Test testTask = binary.getTasks().getRun();

    // Need to provide explicit list of directories to scan for test namespaces in. Not sure it should be in this rule.
    JvmAssembly assembly = ((WithJvmAssembly) binary).getAssembly();
    Stream<File> classDirs = assembly.getClassDirectories().stream();
    Stream<File> resourceDirs = assembly.getResourceDirectories().stream();
    String testDirs = Stream.concat(classDirs, resourceDirs)
        .map(File::getAbsolutePath)
        .collect(Collectors.joining(File.pathSeparator));
    testTask.systemProperty("clojure.test.dirs", testDirs);

    tasks.create(binary.getName() + "GracljTools", Copy.class, task -> {
        testTask.dependsOn(task);
        File tools = internal.resolve("org.graclj:graclj-tools:" + internal.getGracljVersion() + "@jar").getSingleFile();
        task.from(task.getProject().zipTree(tools));
        task.into(binary.getClassesDir());
    });
    testTask.setClasspath(testTask.getClasspath().plus(internal.resolve("org.graclj:graclj-tools:" + internal.getGracljVersion())));
}
项目:JGiven    文件:JGivenPlugin.java   
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask,
        final ReportingExtension reportingExtension ) {
    ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping();
    mapping.map( "results", new Callable<File>() {
        @Override
        public File call() {
            return test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir();
        }
    } );
    mapping.getConventionValue( reportTask.getReports(), "reports", false ).all( new Action<Report>() {
        @Override
        public void execute( final Report report ) {
            ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping();
            reportMapping.map( "destination", new Callable<File>() {
                @Override
                public File call() {
                    return reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() );
                }
            } );
        }
    } );
}
项目:Reer    文件:ClientForwardingTestListener.java   
@Override
public void started(BuildOperationInternal buildOperation, OperationStartEvent startEvent) {
    if (!(buildOperation.getOperationDescriptor() instanceof TaskOperationDescriptor)) {
        return;
    }
    TaskInternal task = ((TaskOperationDescriptor) buildOperation.getOperationDescriptor()).getTask();
    if (!(task instanceof Test)) {
        return;
    }
    runningTasks.put(buildOperation.getId(), task.getPath());
}
项目:Reer    文件:TestExecutionBuildConfigurationAction.java   
@Override
public void configure(BuildExecutionContext context) {
    final Set<Test> allTestTasksToRun = new LinkedHashSet<Test>();
    final GradleInternal gradleInternal = context.getGradle();
    allTestTasksToRun.addAll(configureBuildForTestDescriptors(gradleInternal, testExecutionRequest));
    allTestTasksToRun.addAll(configureBuildForInternalJvmTestRequest(gradleInternal, testExecutionRequest));
    configureTestTasks(allTestTasksToRun);
    gradle.getTaskGraph().addTasks(allTestTasksToRun);
}
项目:Reer    文件:TestExecutionBuildConfigurationAction.java   
private void configureTestTasks(Set<Test> allTestTasksToRun) {
    for (Test task : allTestTasksToRun) {
        task.setIgnoreFailures(true);
        task.getFilter().setFailOnNoMatchingTests(false);
        task.getOutputs().upToDateWhen(Specs.SATISFIES_NONE);
    }
}
项目:Reer    文件:JacocoPlugin.java   
/**
 * Applies the Jacoco agent to all tasks of type {@code Test}.
 *
 * @param extension the extension to apply Jacoco with
 */
private void applyToDefaultTasks(final JacocoPluginExtension extension) {
    project.getTasks().withType(Test.class, new Action<Test>() {
        @Override
        public void execute(Test task) {
            extension.applyTo(task);
        }
    });
}
项目:Reer    文件:JacocoPlugin.java   
private void addDefaultReportTask(final JacocoPluginExtension extension, final Test task) {
    final JacocoReport reportTask = project.getTasks().create("jacoco" + StringUtils.capitalise(task.getName()) + "Report", JacocoReport.class);
    reportTask.executionData(task);
    reportTask.sourceSets(project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main"));
    ConventionMapping taskMapping = ((IConventionAware) reportTask).getConventionMapping();
    taskMapping.getConventionValue(reportTask.getReports(), "reports", false).all(new Action<Report>() {
        @Override
        public void execute(final Report report) {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            // reportMapping.map('enabled', Callables.returning(true));
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                reportMapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + report.getName());
                    }
                });
            } else {
                reportMapping.map("destination", new Callable<File>() {
                    @Override
                    public File call() {
                        return new File(extension.getReportsDir(), task.getName() + "/" + reportTask.getName() + "." + report.getName());
                    }
                });
            }
        }
    });
}
项目:Reer    文件:TestNGTestFramework.java   
public TestNGTestFramework(final Test testTask, DefaultTestFilter filter, Instantiator instantiator, ClassLoaderCache classLoaderCache) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
    classLoaderFactory = new TestClassLoaderFactory(classLoaderCache, testTask);
}
项目:Reer    文件:DefaultTestExecuter.java   
@Override
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final BuildOperationWorkerRegistry.Operation currentOperation = buildOperationWorkerRegistry.getCurrent();
    final Set<File> classpath = ImmutableSet.copyOf(testTask.getClasspath());
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask,
                classpath, testFramework.getWorkerConfigurationAction(), moduleRegistry, currentOperation);
        }
    };
    Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
        }
    };

    TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(),
        reforkingProcessorFactory, actorFactory);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
        testFrameworkDetector.setTestClasspath(classpath);
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }

    final Object testTaskOperationId = buildOperationExecutor.getCurrentOperation().getId();

    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run();
}
项目:Reer    文件:PlayTestPlugin.java   
@Mutate
void attachTestSuitesToCheckTask(ModelMap<Task> tasks, @Path("binaries") final ModelMap<PlayApplicationBinarySpec> playBinaries) {
    // TODO - binaries aren't an input to this rule, they're an input to the action
    tasks.named(LifecycleBasePlugin.CHECK_TASK_NAME, new Action<Task>() {
        @Override
        public void execute(Task checkTask) {
            // TODO Need a better mechanism to wire tasks into lifecycle
            for (PlayApplicationBinarySpec binary : playBinaries) {
                checkTask.dependsOn(binary.getTasks().withType(Test.class));
            }
        }
    });
}
项目:Reer    文件:JavaBasePlugin.java   
private void overwriteDebugIfDebugPropertyIsSet(Test test) {
    String debugProp = getTaskPrefixedProperty(test, "debug");
    if (debugProp != null) {
        test.prependParallelSafeAction(new Action<Task>() {
            public void execute(Task task) {
                task.getLogger().info("Running tests for remote debugging.");
            }
        });
        test.setDebug(true);
    }
}
项目:ide-plugins    文件:EclipseTestExecuter.java   
@Override
public void execute(Test test, TestResultProcessor testResultProcessor) {
    LOGGER.info("Executing tests in Eclipse");

    int pdeTestPort = new PDETestPortLocator().locatePDETestPortNumber();
    if (pdeTestPort == -1) {
        throw new GradleException("Cannot allocate port for PDE test run");
    }
    LOGGER.info("Will use port {} to communicate with Eclipse.", pdeTestPort);

    runPDETestsInEclipse(test, testResultProcessor, pdeTestPort);
}
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Create integration test task
 *
 * @param tasks Task model
 */
@Mutate
public void createIntegrationTask(ModelMap<Test> tasks) {
    tasks.create(INTEGRATION_SOURCE_SET_NAME, t -> {
        t.setDescription("Runs the integration tests");
        t.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
    });
}
项目:gradle-project-config    文件:JavaConfigPlugin.java   
/**
 * Finalize tasks because of {@link JavaPlugin} interference
 *
 * @param tasks Task model
 * @param javaConvention Java conventions
 */
@Finalize
public void finalizeIntegrationTask(ModelMap<Test> tasks, JavaPluginConvention javaConvention) {
    SourceSet source = javaConvention.getSourceSets().getByName(INTEGRATION_SOURCE_SET_NAME);

    tasks.named(INTEGRATION_SOURCE_SET_NAME, t -> {
        t.setClasspath(source.getRuntimeClasspath());
        t.setTestClassesDirs(source.getOutput().getClassesDirs());
    });
}
项目:jovial    文件:JovialPlugin.java   
@Mutate
public void useJovialExecuter(@Each Test task) {
    try {
        Method setter = Test.class.getDeclaredMethod("setTestExecuter", TestExecuter.class);
        setter.setAccessible(true);
        setter.invoke(task, new JovialTestExecuter());
    } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
        throw new AssertionError("This setTestExecuter should exist.", e);
    }
}
项目:intellij-ce-playground    文件:TaskManager.java   
private static void fixTestTaskSources(@NonNull Test testTask) {
    // We are running in afterEvaluate, so the JavaBasePlugin has already added a
    // callback to add test classes to the list of source files of the newly created task.
    // The problem is that we haven't configured the test classes yet (JavaBasePlugin
    // assumes all Test tasks are fully configured at this point), so we have to remove the
    // "directory null" entry from source files and add the right value.
    //
    // This is an ugly hack, since we assume sourceFiles is an instance of
    // DefaultConfigurableFileCollection.
    ((DefaultConfigurableFileCollection) testTask.getInputs().getSourceFiles()).getFrom().clear();
}
项目:putnami-gradle-plugin    文件:PwtLibPlugin.java   
private void includeSourcesForTest(Project project) {
    JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    SourceSet mainSourset = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    SourceSet testSourset = javaConvention.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);

    FileCollection testClasspath = project
        .files(mainSourset.getAllSource().getSrcDirs().toArray())
        .plus(project.files(testSourset.getAllSource().getSrcDirs().toArray()))
        .plus(testSourset.getRuntimeClasspath());
    testSourset.setRuntimeClasspath(testClasspath);

    Test test = project.getTasks().withType(Test.class).getByName("test");
    test.getSystemProperties().put("gwt.persistentunitcachedir", project.getBuildDir() + "/putnami/test");
}
项目:Pushjet-Android    文件:TestNGTestFramework.java   
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
项目:Pushjet-Android    文件:DefaultTestExecuter.java   
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask,
                    testTask.getClasspath(), testFramework.getWorkerConfigurationAction());
        }
    };
    Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
        }
    };

    TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(),
            reforkingProcessorFactory, actorFactor);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
        testFrameworkDetector.setTestClasspath(testTask.getClasspath());
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }
    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider()).run();
}
项目:Pushjet-Android    文件:JavaBasePlugin.java   
private void overwriteDebugIfDebugPropertyIsSet(Test test) {
    String debugProp = getTaskPrefixedProperty(test, "debug");
    if (debugProp != null) {
        test.doFirst(new Action<Task>() {
            public void execute(Task task) {
                task.getLogger().info("Running tests for remote debugging.");
            }
        });
        test.setDebug(true);
    }
}
项目:Pushjet-Android    文件:TestNGTestFramework.java   
public TestNGTestFramework(Test testTask, DefaultTestFilter filter, Instantiator instantiator) {
    this.testTask = testTask;
    this.filter = filter;
    options = instantiator.newInstance(TestNGOptions.class, testTask.getProject().getProjectDir());
    options.setAnnotationsOnSourceCompatibility(JavaVersion.toVersion(testTask.getProject().property("sourceCompatibility")));
    conventionMapOutputDirectory(options, testTask.getReports().getHtml());
    detector = new TestNGDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
项目:Pushjet-Android    文件:DefaultTestExecuter.java   
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask,
                    testTask.getClasspath(), testFramework.getWorkerConfigurationAction());
        }
    };
    Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
        public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
        }
    };

    TestClassProcessor processor = new MaxNParallelTestClassProcessor(testTask.getMaxParallelForks(),
            reforkingProcessorFactory, actorFactor);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
        TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
        testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
        testFrameworkDetector.setTestClasspath(testTask.getClasspath());
        detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
        detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }
    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider()).run();
}
项目:gradle-metrics-plugin    文件:MetricsPlugin.java   
private void configureProjectCollectors(Set<Project> projects) {
    for (Project project : projects) {
        TaskContainer tasks = project.getTasks();
        for (String name : tasks.getNames()) {
            Task task = tasks.getByName(name);
            if (task instanceof Test) {
                GradleTestSuiteCollector suiteCollector = new GradleTestSuiteCollector(dispatcherSupplier, (Test) task);
                ((Test) task).addTestListener(suiteCollector);
            }
        }
    }
}
项目:okbuck    文件:JvmTarget.java   
/**
 * The test options
 * @return The test options
 */
public TestOptions getTestOptions() {
    try {
        Test testTask = getProject().getTasks().withType(Test.class).getByName("test");
        List<String> jvmArgs = testTask != null ? testTask.getAllJvmArgs() : Collections.emptyList();
        Map<String, Object> env = testTask != null ? testTask.getEnvironment() : Collections.emptyMap();
        env.keySet().removeAll(System.getenv().keySet());
        return new TestOptions(jvmArgs, env);
    } catch (Exception e) {
        return TestOptions.EMPTY;
    }
}
项目:okbuck    文件:JvmTarget.java   
/**
 * The test options
 * @return The test options
 */
public TestOptions getTestOptions() {
    try {
        Test testTask = getProject().getTasks().withType(Test.class).getByName("test");
        List<String> jvmArgs = testTask != null ? testTask.getAllJvmArgs() : Collections.emptyList();
        Map<String, Object> env = testTask != null ? testTask.getEnvironment() : Collections.emptyMap();
        env.keySet().removeAll(System.getenv().keySet());
        return new TestOptions(jvmArgs, env);
    } catch (Exception e) {
        return TestOptions.EMPTY;
    }
}
项目:JGiven    文件:JGivenPlugin.java   
private void addTaskExtension( Project project ) {
    project.getTasks().withType( Test.class, new Action<Test>() {
        @Override
        public void execute( Test test ) {
            applyTo( test );
        }
    } );
}
项目:JGiven    文件:JGivenPlugin.java   
private void addDefaultReports( final Project project ) {
    final ReportingExtension reportingExtension = project.getExtensions().findByType( ReportingExtension.class );
    project.getTasks().withType( Test.class, new Action<Test>() {
        @Override
        public void execute( final Test test ) {
            final JGivenReportTask reportTask = project.getTasks()
                    .create( "jgiven" + WordUtil.capitalize( test.getName() ) + "Report", JGivenReportTask.class );
            configureDefaultReportTask( test, reportTask, reportingExtension );
        }
    } );
}
项目:gradle-circle-style    文件:CircleBuildFailureListener.java   
private boolean isUntracked(Task task) {
    return !(task instanceof Test) && !isStyleTask(task);
}
项目:Reer    文件:DefaultJUnitTestSuiteBinarySpec.java   
@Override
public Test getRun() {
    return findSingleTaskWithType(Test.class);
}
项目:Reer    文件:JvmTestSuiteBinarySpec.java   
@Override
Test getRun();
项目:Reer    文件:JUnitTestFramework.java   
public JUnitTestFramework(Test testTask, DefaultTestFilter filter) {
    this.filter = filter;
    options = new JUnitOptions();
    detector = new JUnitDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}