Search in sources :

Example 31 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class WarPluginActionIntegrationTests method errorMessageIsHelpfulWhenMainClassCannotBeResolved.

@TestTemplate
void errorMessageIsHelpfulWhenMainClassCannotBeResolved() {
    BuildResult result = this.gradleBuild.buildAndFail("build", "-PapplyWarPlugin");
    assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.FAILED);
    assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 32 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootRunIntegrationTests method optimizedLaunchDisabledJvmArgs.

@TestTemplate
void optimizedLaunchDisabledJvmArgs() throws IOException {
    copyJvmArgsApplication();
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).doesNotContain("-Xverify:none").doesNotContain("-XX:TieredStopAtLevel=1");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 33 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootRunIntegrationTests method defaultJvmArgs.

@TestTemplate
void defaultJvmArgs() throws IOException {
    copyJvmArgsApplication();
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
        assertThat(result.getOutput()).contains("1. -XX:TieredStopAtLevel=1");
    } else {
        assertThat(result.getOutput()).contains("1. -Xverify:none").contains("2. -XX:TieredStopAtLevel=1");
    }
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 34 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootRunIntegrationTests method applicationPluginMainClassNameIsUsed.

@TestTemplate
void applicationPluginMainClassNameIsUsed() throws IOException {
    copyMainClassApplication();
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 35 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project spring-boot by spring-projects.

the class BootRunIntegrationTests method sourceResourcesCanBeUsed.

@TestTemplate
void sourceResourcesCanBeUsed() throws IOException {
    copyClasspathApplication();
    BuildResult result = this.gradleBuild.build("bootRun");
    assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
    assertThat(result.getOutput()).contains("1. " + canonicalPathOf("src/main/resources"));
    assertThat(result.getOutput()).contains("2. " + canonicalPathOf("build/classes/java/main"));
    assertThat(result.getOutput()).doesNotContain(canonicalPathOf("build/resources/main"));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

BuildResult (org.gradle.testkit.runner.BuildResult)149 File (java.io.File)65 TestTemplate (org.junit.jupiter.api.TestTemplate)60 Test (org.junit.Test)47 Test (org.junit.jupiter.api.Test)21 StringWriter (java.io.StringWriter)19 GradleRunner (org.gradle.testkit.runner.GradleRunner)17 Test (org.testng.annotations.Test)10 ImageReference (org.springframework.boot.buildpack.platform.docker.type.ImageReference)8 JarFile (java.util.jar.JarFile)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 TestHelpers.findFile (me.tatarka.TestHelpers.findFile)6 TestHelpers.writeFile (me.tatarka.TestHelpers.writeFile)6 ContainerConfig (com.github.dockerjava.api.model.ContainerConfig)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 PrintWriter (java.io.PrintWriter)5 Path (java.nio.file.Path)5 BuildTask (org.gradle.testkit.runner.BuildTask)5