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

下面列出了怎么用org.gradle.api.tasks.testing.Test的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gradle-modules-plugin   文件: TestTask.java
private void configureTestJava(Test testJava) {
    var testModuleOptions = testJava.getExtensions().create("moduleOptions", TestModuleOptions.class, project);

    // don't convert to lambda: https://github.com/java9-modularity/gradle-modules-plugin/issues/54
    testJava.doFirst(new Action<Task>() {
        @Override
        public void execute(Task task) {
            if (testModuleOptions.getRunOnClasspath()) {
                LOGGER.lifecycle("Running tests on classpath");
                return;
            }

            List<String> args = buildJvmArgs(testJava, testModuleOptions);
            testJava.setJvmArgs(args);
            testJava.setClasspath(project.files());
        }
    });
}
 
源代码2 项目: pushfish-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));
}
 
源代码3 项目: pushfish-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());
}
 
源代码4 项目: quarkus   文件: QuarkusPluginExtension.java
void beforeTest(Test task) {
    try {
        final Map<String, Object> props = task.getSystemProperties();

        final AppModel appModel = getAppModelResolver(LaunchMode.TEST)
                .resolveModel(getAppArtifact());
        final Path serializedModel = QuarkusGradleUtils.serializeAppModel(appModel, task);
        props.put(BootstrapConstants.SERIALIZED_APP_MODEL, serializedModel.toString());

        final String nativeRunner = task.getProject().getBuildDir().toPath().resolve(finalName() + "-runner")
                .toAbsolutePath()
                .toString();
        props.put("native.image.path", nativeRunner);
    } catch (Exception e) {
        throw new IllegalStateException("Failed to resolve deployment classpath", e);
    }
}
 
源代码5 项目: 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());
        }
    });
}
 
源代码6 项目: javaide   文件: 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("test.candidateClassFiles").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));
}
 
源代码7 项目: javaide   文件: 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());
}
 
源代码8 项目: 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));
}
 
源代码9 项目: 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());
}
 
源代码10 项目: JGiven   文件: JGivenPlugin.java
private void applyTo( Test test ){
    final String testName = test.getName();
    final JGivenTaskExtension extension = test.getExtensions().create( "jgiven", JGivenTaskExtension.class );
    final Project project = test.getProject();
    ( (IConventionAware) extension ).getConventionMapping().map( "resultsDir",
            (Callable<File>) () -> project.file( project.getBuildDir() + "/jgiven-results/" + testName ) );

    File resultsDir = extension.getResultsDir();
    if( resultsDir != null ) {
        test.getOutputs().dir( resultsDir ).withPropertyName( "jgiven.resultsDir" );
    }

    // Java lambda classes are created at runtime with a non-deterministic classname.
    // Therefore, the class name does not identify the implementation of the lambda and changes between different Gradle runs.
    // https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:how_does_it_work
    test.prependParallelSafeAction( new Action<Task>() {
        @Override
        public void execute( Task task ){
            ((Test) task).systemProperty( Config.JGIVEN_REPORT_DIR, extension.getResultsDir().getAbsolutePath() );
        }
    } );
}
 
源代码11 项目: gradle-modules-plugin   文件: TestTask.java
private List<String> buildJvmArgs(Test testJava, TestModuleOptions testModuleOptions) {
    var jvmArgs = new ArrayList<>(testJava.getJvmArgs());


    FileCollection classpath = mergeClassesHelper().getMergeAdjustedClasspath(testJava.getClasspath());
    var patchModuleContainer = PatchModuleContainer.copyOf(
            helper().modularityExtension().optionContainer().getPatchModuleContainer());
    String moduleName = helper().moduleName();
    buildPatchModulePathStream().forEach(path -> patchModuleContainer.addDir(moduleName, path.toString()));
    patchModuleContainer.buildModulePathOption(classpath).ifPresent(option -> option.mutateArgs(jvmArgs));

    patchModuleContainer.mutator(classpath).mutateArgs(jvmArgs);

    new TaskOption("--add-modules", "ALL-MODULE-PATH").mutateArgs(jvmArgs);

    testModuleOptions.mutateArgs(jvmArgs);

    TestEngine.selectMultiple(project).forEach(testEngine -> {
        buildAddReadsOption(testEngine).mutateArgs(jvmArgs);
        buildAddOpensOptionStream(testEngine).forEach(option -> option.mutateArgs(jvmArgs));
        testEngine.additionalTaskOptions.forEach(option -> option.mutateArgs(jvmArgs));
    });

    ModuleInfoTestHelper.mutateArgs(project, jvmArgs::add);

    return jvmArgs;
}
 
源代码12 项目: pushfish-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()));
}
 
源代码13 项目: pushfish-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();
}
 
源代码14 项目: pushfish-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);
    }
}
 
源代码15 项目: pushfish-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()));
}
 
源代码16 项目: pushfish-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();
}
 
源代码17 项目: transport   文件: TransportPlugin.java
/**
 * Configures SourceSets, dependencies and tasks related to each Transport UDF platform
 */
private void configurePlatform(Project project, Platform platform, SourceSet mainSourceSet, SourceSet testSourceSet,
    File baseOutputDir) {
  SourceSet sourceSet = configureSourceSet(project, platform, mainSourceSet, baseOutputDir);
  configureGenerateWrappersTask(project, platform, mainSourceSet, sourceSet);
  List<TaskProvider<? extends Task>> packagingTasks =
      configurePackagingTasks(project, platform, sourceSet, mainSourceSet);
  // Add Transport tasks to build task dependencies
  project.getTasks().named(LifecycleBasePlugin.BUILD_TASK_NAME).configure(task -> task.dependsOn(packagingTasks));

  TaskProvider<Test> testTask = configureTestTask(project, platform, mainSourceSet, testSourceSet);
  project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(task -> task.dependsOn(testTask));
}
 
源代码18 项目: javaide   文件: 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);
    }
}
 
@Override
public void apply(Project project) {
    project.getPlugins().apply(JacocoPlugin.class);

    project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> {

        reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
        reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath()));

        project.allprojects(subproject -> {
            subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
                SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
                SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
                reportTask.sourceSets(main);
            });

            subproject.getTasks()
                    .withType(Test.class)
                    .forEach(reportTask::executionData);
        });

        JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class);
        reportTask.getReports().getHtml().setEnabled(true);
        reportTask.getReports().all(report -> {
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName())));
            }
            else {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName())));
            }
        });
    });


}
 
@Override
public void apply(Project project) {
    project.getPlugins().apply(JacocoPlugin.class);

    project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> {

        reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
        reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath()));

        project.allprojects(subproject -> {
            subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
                SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
                SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
                reportTask.sourceSets(main);
            });

            subproject.getTasks()
                    .withType(Test.class)
                    .forEach(reportTask::executionData);
        });

        JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class);
        reportTask.getReports().getHtml().setEnabled(true);
        reportTask.getReports().all(report -> {
            if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName())));
            }
            else {
                report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName())));
            }
        });
    });


}
 
源代码21 项目: 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");
}
 
源代码22 项目: 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()));
}
 
源代码23 项目: 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();
}
 
源代码24 项目: 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);
    }
}
 
源代码25 项目: 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()));
}
 
源代码26 项目: 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();
}
 
源代码27 项目: JGiven   文件: JGivenPlugin.java
private void addDefaultReports( final Project project ){
    final ReportingExtension reportingExtension = project.getExtensions().findByType( ReportingExtension.class );
    project.getTasks().withType( Test.class, test -> {
        final JGivenReportTask reportTask = project.getTasks()
                .create( "jgiven" + WordUtil.capitalize( test.getName() ) + "Report", JGivenReportTask.class );
        configureDefaultReportTask( test, reportTask, reportingExtension );
    } );
}
 
源代码28 项目: JGiven   文件: JGivenPlugin.java
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask,
        final ReportingExtension reportingExtension ){
    ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping();
    mapping.map( "results", (Callable<File>) () -> test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir() );
    mapping.getConventionValue( reportTask.getReports(), "reports", false )
            .all( (Action<Report>) report -> {
                ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping();
                reportMapping.map( "destination",
                        (Callable<File>) () -> reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() ) );
            } );
}
 
源代码29 项目: gradle-modules-plugin   文件: TestTask.java
public void configureTestJava() {
    helper().findTask(JavaPlugin.TEST_TASK_NAME, Test.class)
            .ifPresent(this::configureTestJava);
}
 
源代码30 项目: pushfish-android   文件: JUnitTestFramework.java
public JUnitTestFramework(Test testTask, DefaultTestFilter filter) {
    this.testTask = testTask;
    this.filter = filter;
    options = new JUnitOptions();
    detector = new JUnitDetector(new ClassFileExtractionManager(testTask.getTemporaryDirFactory()));
}
 
 类所在包
 类方法
 同包方法