use of org.gradle.testkit.runner.BuildResult in project auto by google.
the class GradleTest method basic.
@Test
public void basic() throws IOException {
String autoValueVersion = System.getProperty("autoValueVersion");
assertThat(autoValueVersion).isNotNull();
String localRepository = System.getProperty("localRepository");
assertThat(localRepository).isNotNull();
// Set up the fake Gradle project.
String buildGradleText = expandSystemProperties(BUILD_GRADLE_TEXT);
writeFile(fakeProject.newFile("build.gradle").toPath(), buildGradleText);
Path srcDir = fakeProject.newFolder("src", "main", "java", "com", "example").toPath();
writeFile(srcDir.resolve("Foo.java"), FOO_TEXT);
// Build it the first time.
BuildResult result1 = buildFakeProject();
assertThat(result1.getOutput()).contains("Full recompilation is required because no incremental change information is" + " available");
Path output = fakeProject.getRoot().toPath().resolve("build/classes/java/main/com/example/AutoValue_Foo.class");
assertThat(Files.exists(output)).isTrue();
// Add a source file to the project.
String barText = FOO_TEXT.replace("Foo", "Bar");
Path barFile = srcDir.resolve("Bar.java");
writeFile(barFile, barText);
// Build it a second time.
BuildResult result2 = buildFakeProject();
assertThat(result2.getOutput()).doesNotContain("Full recompilation is required");
// Remove the second source file and build a third time. If incremental annotation processing
// is not working, this will produce a message like this:
// Full recompilation is required because com.google.auto.value.processor.AutoValueProcessor
// is not incremental
Files.delete(barFile);
BuildResult result3 = buildFakeProject();
assertThat(result3.getOutput()).doesNotContain("Full recompilation is required");
}
use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.
the class TestFailuresPluginIntegrationTests method multiProjectContinue.
@Test
void multiProjectContinue() throws IOException {
createMultiProjectBuild();
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir).withArguments("build", "--continue").withPluginClasspath().buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 2 test tasks:", "", ":project-one:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", " example.MoreTests > bad()", " example.MoreTests > fail()", "", ":project-two:test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", " example.MoreTests > bad()", " example.MoreTests > fail()", "");
}
use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.
the class TestFailuresPluginIntegrationTests method singleProject.
@Test
void singleProject() throws IOException {
createProject(this.projectDir);
BuildResult result = GradleRunner.create().withDebug(true).withProjectDir(this.projectDir).withArguments("build").withPluginClasspath().buildAndFail();
assertThat(readLines(result.getOutput())).containsSequence("Found test failures in 1 test task:", "", ":test", " example.ExampleTests > bad()", " example.ExampleTests > fail()", " example.MoreTests > bad()", " example.MoreTests > fail()", "");
}
use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.
the class OptionalDependenciesPluginIntegrationTests method optionalConfigurationIsCreated.
@Test
void optionalConfigurationIsCreated() throws IOException {
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {
out.println("plugins { id 'org.springframework.boot.optional-dependencies' }");
out.println("task printConfigurations {");
out.println(" doLast {");
out.println(" configurations.all { println it.name }");
out.println(" }");
out.println("}");
}
BuildResult buildResult = runGradle("printConfigurations");
assertThat(buildResult.getOutput()).contains(OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME);
}
use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.
the class SpringBootPluginIntegrationTests method failFastWithVersionOfGradle7LowerThanRequired.
@DisabledForJreRange(min = JRE.JAVA_14)
@Test
void failFastWithVersionOfGradle7LowerThanRequired() {
BuildResult result = this.gradleBuild.gradleVersion("7.3.3").buildAndFail();
assertThat(result.getOutput()).contains("Spring Boot plugin requires Gradle 7.x (7.4 or later). The current version is Gradle 7.3.3");
}
Aggregations