org.gradle.api.tasks.testing.Test Java Examples
The following examples show how to use
org.gradle.api.tasks.testing.Test.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestTask.java From gradle-modules-plugin with MIT License | 6 votes |
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()); } }); }
Example #2
Source File: JigsawPlugin.java From gradle-java-modules with Apache License 2.0 | 6 votes |
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()); } }); }
Example #3
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
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)); }
Example #4
Source File: QuarkusPluginExtension.java From quarkus with Apache License 2.0 | 6 votes |
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); } }
Example #5
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
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()); }
Example #6
Source File: JavaBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #7
Source File: JavaBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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)); }
Example #8
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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)); }
Example #9
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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()); }
Example #10
Source File: JGivenPlugin.java From JGiven with Apache License 2.0 | 6 votes |
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() ); } } ); }
Example #11
Source File: TestNGTestFramework.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example #12
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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); } }
Example #13
Source File: DefaultTestExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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(); }
Example #14
Source File: TestNGTestFramework.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example #15
Source File: PwtLibPlugin.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 5 votes |
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"); }
Example #16
Source File: AggregateJacocoReportPlugin.java From gradle-plugins with MIT License | 5 votes |
@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()))); } }); }); }
Example #17
Source File: AggregateJacocoReportPlugin.java From gradle-plugins with MIT License | 5 votes |
@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()))); } }); }); }
Example #18
Source File: DefaultTestExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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(); }
Example #19
Source File: JGivenPlugin.java From JGiven with Apache License 2.0 | 5 votes |
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 ); } ); }
Example #20
Source File: JGivenPlugin.java From JGiven with Apache License 2.0 | 5 votes |
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() ) ); } ); }
Example #21
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 5 votes |
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); } }
Example #22
Source File: TestTask.java From gradle-modules-plugin with MIT License | 5 votes |
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; }
Example #23
Source File: TransportPlugin.java From transport with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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)); }
Example #24
Source File: TestNGTestFramework.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example #25
Source File: DefaultTestExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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(); }
Example #26
Source File: DefaultTestExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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(); }
Example #27
Source File: TestNGTestFramework.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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())); }
Example #28
Source File: JavaBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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); } }
Example #29
Source File: TestTask.java From gradle-modules-plugin with MIT License | 4 votes |
public void configureTestJava() { helper().findTask(JavaPlugin.TEST_TASK_NAME, Test.class) .ifPresent(this::configureTestJava); }
Example #30
Source File: JGivenPlugin.java From JGiven with Apache License 2.0 | 4 votes |
private void addTaskExtension( Project project ){ project.getTasks().withType( Test.class, this::applyTo ); }