Search in sources :

Example 1 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project byte-buddy by raphw.

the class ByteBuddyPluginTest method makePluginJar.

private static File makePluginJar() throws IOException {
    File pluginFolder = TEMPORARY_FOLDER.newFolder("test-byte-buddy-plugin");
    store("plugins { id 'java' }\n" + "repositories {\n" + "  mavenLocal()\n" + "  mavenCentral()\n" + "}\n" + "dependencies {\n" + "  compile 'net.bytebuddy:byte-buddy:" + BYTE_BUDDY_VERSION + "'\n" + "}\n", new File(pluginFolder, "build.gradle"));
    File pluginRoot = new File(pluginFolder, "src/main/java/net/bytebuddy/test");
    assertThat(pluginRoot.mkdirs(), is(true));
    store("package net.bytebuddy.test;\n" + "\n" + "import net.bytebuddy.build.Plugin;\n" + "import net.bytebuddy.description.type.TypeDescription;\n" + "import net.bytebuddy.dynamic.DynamicType;\n" + "import net.bytebuddy.implementation.FixedValue;\n" + "\n" + "import static net.bytebuddy.matcher.ElementMatchers.named;\n" + "\n" + "public class SimplePlugin implements Plugin {\n" + "    @Override\n" + "    public boolean matches(TypeDescription target) {\n" + "        return target.getName().equals(\"net.bytebuddy.test.Sample\");\n" + "    }\n" + "    @Override\n" + "    public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription) {\n" + "        return builder.method(named(\"foo\")).intercept(FixedValue.value(\"qux\"));\n" + "    }\n" + "}\n", new File(pluginRoot, "SimplePlugin.java"));
    BuildResult result = GradleRunner.create().withProjectDir(pluginFolder).withArguments("jar").build();
    assertThat(result.task(":jar").getOutcome(), is(TaskOutcome.SUCCESS));
    return new File(pluginFolder, "build/libs/test-byte-buddy-plugin.jar");
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult)

Example 2 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project lightning by automatictester.

the class GradleCompatibilityTest method checkGradleCompatibility.

@Test(dataProvider = "getGradleVersions")
public void checkGradleCompatibility(String gradleVersion) {
    BuildResult result = GradleRunner.create().withGradleVersion(gradleVersion).withProjectDir(new File("src/integrationTest/resources/build/complete")).withArguments(":report").withPluginClasspath().build();
    assertThat(result.task(":report").getOutcome(), is(SUCCESS));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project lightning by automatictester.

the class ReportTaskTest method runReport.

@Test
public void runReport() {
    BuildResult result = GradleRunner.create().withProjectDir(new File("src/integrationTest/resources/build/complete")).withArguments(":report").withPluginClasspath().build();
    assertThat(result.task(":report").getOutcome(), is(SUCCESS));
    assertThat(taskOutputContainsFileContent("/results/expected/report.txt", result), is(true));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project lightning by automatictester.

the class VerifyTaskTest method runVerifyAndCheckJUnitReport.

@Test
public void runVerifyAndCheckJUnitReport() throws IOException {
    BuildResult result = GradleRunner.create().withProjectDir(new File("src/integrationTest/resources/build/junit")).withArguments(":verify").withPluginClasspath().buildAndFail();
    assertThat(result.task(":verify").getOutcome(), is(FAILED));
    assertThat(fileContentIsEqual("/results/expected/junit-expected.xml", "junit.xml"), is(true));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with BuildResult

use of org.gradle.testkit.runner.BuildResult in project lightning by automatictester.

the class VerifyTaskTest method runVerifyWithFailureAndError.

@Test
public void runVerifyWithFailureAndError() {
    BuildResult result = GradleRunner.create().withProjectDir(new File("src/integrationTest/resources/build/1_1_1")).withArguments(":verify").withPluginClasspath().buildAndFail();
    assertThat(result.task(":verify").getOutcome(), is(FAILED));
    assertThat(taskOutputContainsFileContent("/results/expected/1_1_1.txt", result), is(true));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

BuildResult (org.gradle.testkit.runner.BuildResult)143 File (java.io.File)62 TestTemplate (org.junit.jupiter.api.TestTemplate)60 Test (org.junit.Test)47 Test (org.junit.jupiter.api.Test)20 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 BufferedReader (java.io.BufferedReader)4