org.gradle.testkit.runner.BuildTask Java Examples

The following examples show how to use org.gradle.testkit.runner.BuildTask. 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: BuildResultAssert.java    From curiostack with MIT License 5 votes vote down vote up
/** Asserts that the {@code tasks} succeeded during the build. */
public BuildResultAssert tasksDidSucceed(Iterable<String> tasks) {
  tasksDidRun(tasks);
  SoftAssertions.assertSoftly(
      softly -> {
        for (var task : tasks) {
          BuildTask result = actual.task(task);
          softly
              .assertThat(result.getOutcome())
              .as("Task %s did not succeed", task)
              .isEqualTo(TaskOutcome.SUCCESS);
        }
      });
  return this;
}
 
Example #2
Source File: BuildResultAssert.java    From curiostack with MIT License 5 votes vote down vote up
/** Asserts that the {@code tasks} succeeded during the build. */
public BuildResultAssert tasksDidRun(Iterable<String> tasks) {
  SoftAssertions.assertSoftly(
      softly -> {
        for (var task : tasks) {
          BuildTask result = actual.task(task);
          softly.assertThat(result).as("Task %s did not run", task).isNotNull();
        }
      });
  return this;
}
 
Example #3
Source File: BuildResultAssert.java    From curiostack with MIT License 5 votes vote down vote up
/** Asserts that the {@code tasks} succeeded during the build. */
public BuildResultAssert tasksDidNotRun(Iterable<String> tasks) {
  SoftAssertions.assertSoftly(
      softly -> {
        for (var task : tasks) {
          BuildTask result = actual.task(task);
          softly.assertThat(result).as("Task %s did not run", task).isNull();
        }
      });
  return this;
}
 
Example #4
Source File: JoinfacesPluginIT.java    From joinfaces with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"5.1.1", "5.4.1", "5.6.2"})
public void build(String gradleVersion, @TempDir Path projectDir) throws IOException {
	Files.write(projectDir.resolve("settings.gradle"), Collections.singleton("rootProject.name = 'dummy'"));

	Files.write(projectDir.resolve("build.gradle"), Arrays.asList(
			"plugins {",
			"    id 'java'",
			"    id 'groovy'",
			"    id 'scala'",
			"    id 'org.joinfaces'",
			"}",
			"repositories { mavenCentral() }",
			"dependencies {",
			"    compile 'org.apache.myfaces.core:myfaces-impl:2.3.2'",
			"}"
	));

	BuildResult buildResult = GradleRunner.create()
			.withProjectDir(projectDir.toFile())
			.withPluginClasspath()
			.withArguments("jar", "-s", "--info")
			.withDebug(true)
			.withGradleVersion(gradleVersion)
			.build();

	BuildTask scanClasspath = buildResult.task(":scanJoinfacesClasspath");
	assertThat(scanClasspath).isNotNull();
	assertThat(scanClasspath.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);

	File jarFile = projectDir.resolve("build/libs/dummy.jar").toFile();
	assertThat(jarFile).isFile();

	try (ZipFile zipFile = new ZipFile(jarFile)) {
		assertThat(zipFile.getEntry("META-INF/joinfaces/org.apache.myfaces.ee.MyFacesContainerInitializer.classes")).isNotNull();
		assertThat(zipFile.getEntry("META-INF/joinfaces/org.apache.myfaces.spi.AnnotationProvider.classes")).isNotNull();
	}
}
 
Example #5
Source File: FunctionalDownloadTest.java    From gradle-download-task with Apache License 2.0 5 votes vote down vote up
/**
 * Create a task
 * @param taskName the task's name
 * @param parameters the download parameters
 * @return the task
 * @throws Exception if anything went wrong
 */
protected BuildTask runTask(String taskName, Parameters parameters) throws Exception {
    return createRunner(parameters)
            .withArguments(parameters.offline ? asList("--offline", taskName) :
                singletonList(taskName))
            .build()
            .task(taskName);
}
 
Example #6
Source File: SmokeTestHelper.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
static void assertTaskSuccessful(BuildResult result, String subprojectName, String taskName) {
    String fullTaskName = String.format(":%s:%s", subprojectName, taskName);
    BuildTask task = Objects.requireNonNull(result.task(fullTaskName), fullTaskName);
    assertEquals(TaskOutcome.SUCCESS, task.getOutcome(), () -> fullTaskName + " failed!");
}
 
Example #7
Source File: ScoverageFunctionalTest.java    From gradle-scoverage with Apache License 2.0 4 votes vote down vote up
public void assertTaskSkipped(String taskName) {

            BuildTask task = getTask(taskName);
            Assert.assertTrue(task == null || task.getOutcome() == TaskOutcome.SKIPPED);
        }
 
Example #8
Source File: FunctionalTestBase.java    From gradle-download-task with Apache License 2.0 4 votes vote down vote up
/**
 * Asserts that a given task was successful
 * @param task the task
 */
protected void assertTaskSuccess(BuildTask task) {
    assertNotNull("task is null", task);
    assertEquals("task " + task + " state should be success", SUCCESS, task.getOutcome());
}
 
Example #9
Source File: FunctionalTestBase.java    From gradle-download-task with Apache License 2.0 4 votes vote down vote up
/**
 * Asserts that a given task has been marked as up-to-date
 * @param task the task
 */
protected void assertTaskUpToDate(BuildTask task) {
    assertNotNull("task is null", task);
    assertEquals("task " + task + " state should be up-to-date", UP_TO_DATE, task.getOutcome());
}
 
Example #10
Source File: FunctionalTestBase.java    From gradle-download-task with Apache License 2.0 4 votes vote down vote up
/**
 * Asserts that a given task has been marked as skipped
 * @param task the task
 */
protected void assertTaskSkipped(BuildTask task) {
    assertNotNull("task is null", task);
    assertEquals("task " + task + " state should be skipped", SKIPPED, task.getOutcome());
}
 
Example #11
Source File: ScoverageFunctionalTest.java    From gradle-scoverage with Apache License 2.0 3 votes vote down vote up
public void assertTaskOutcome(String taskName, TaskOutcome outcome) {

            BuildTask task = getTask(taskName);
            Assert.assertNotNull(task);
            Assert.assertEquals(outcome, task.getOutcome());

        }
 
Example #12
Source File: ScoverageFunctionalTest.java    From gradle-scoverage with Apache License 2.0 2 votes vote down vote up
private BuildTask getTask(String taskName) {

            return result.task(fullTaskName(taskName));
        }
 
Example #13
Source File: FunctionalDownloadTest.java    From gradle-download-task with Apache License 2.0 2 votes vote down vote up
/**
 * Create a download task
 * @param parameters the download parameters
 * @return the download task
 * @throws Exception if anything went wrong
 */
protected BuildTask download(Parameters parameters) throws Exception {
    return runTask(":downloadTask", parameters);
}