Java Code Examples for org.gradle.api.tasks.testing.Test#doFirst()
The following examples show how to use
org.gradle.api.tasks.testing.Test#doFirst() .
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: 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 3
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 4
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 5
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 6
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); } }