org.gradle.testkit.runner.BuildResult Java Examples
The following examples show how to use
org.gradle.testkit.runner.BuildResult.
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: ModuleInitTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
public void runTaskInitTest(File apiFile, String modExtension, File buildFile, File outDir) throws IOException { StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n") .append("task initModuleTest(type: com.marklogic.client.tools.gradle.ModuleInitTask) {\n") .append(" endpointDeclarationFile = '"+apiFile.getPath()+"'\n") .append(" moduleExtension = '"+modExtension+"'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments("initModuleTest") .withDebug(true) .build(); File modFile = new File(outDir, testEnv.baseName + "." + modExtension); assertTrue("task init did not generate "+modFile.getPath(), modFile.exists()); buildFile.delete(); modFile.delete(); }
Example #2
Source File: EndpointsClientPluginTest.java From endpoints-framework-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testClientBuilds() throws IOException, URISyntaxException { BuildResult buildResult = new TestProject(testProjectDir.getRoot(), "projects/client") .gradleRunnerArguments("assemble") .build(); // Part of what we're testing is that a class with a dependency on generated source will compile // correctly when the generated source is created at build time. The above build will fail with // a gradle exception if generation and association of the generated source with the project // does not happen correctly. File genSrcDir = new File(testProjectDir.getRoot(), "build/endpointsGenSrc"); File genSrcFile = new File(genSrcDir, "com/example/testApi/TestApi.java"); Assert.assertTrue(genSrcFile.exists()); }
Example #3
Source File: ServiceCompareTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
@Test public void testTaskCheckOneArg() throws IOException { initTestEnv(); StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n") .append("task serviceCompareTest(type: com.marklogic.client.tools.gradle.ServiceCompareTask) {\n") .append(" customSeviceDeclarationFile = '"+testEnv.customServiceDir.getPath()+"/service.json'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments("serviceCompareTest") .withDebug(true) .build(); assertTrue("one argument task failed", result.getOutput().contains("BUILD SUCCESSFUL")); testEnv.buildFile.delete(); }
Example #4
Source File: ServiceCompareTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
@Test public void testCommandLineCheckOneArg() throws IOException { initTestEnv(); StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments( "-PcustomSeviceDeclarationFile="+testEnv.customServiceDir.getPath()+"/service.json", "checkCustomService" ) .withDebug(true) .build(); assertTrue("one argument command failed", result.getOutput().contains("BUILD SUCCESSFUL")); testEnv.buildFile.delete(); }
Example #5
Source File: AppEngineAppYamlPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeploy_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineDeploy", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":assemble", ":downloadCloudSdk", ":appengineStage", ":appengineDeploy"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #6
Source File: ModuleInitTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
public void runCommandLineInitTest(File apiFile, String modExtension, File buildFile, File outDir) throws IOException { StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments( "-PendpointDeclarationFile="+apiFile.getPath(), "-PmoduleExtension="+modExtension, "initializeModule" ) .withDebug(true) .build(); File modFile = new File(outDir, testEnv.baseName + "." + modExtension); assertTrue("command line did not generate "+modFile.getPath(), modFile.exists()); buildFile.delete(); modFile.delete(); }
Example #7
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 6 votes |
@Test public void canRunTaskGenerateDrivenAdapterEventBusTest() { canRunTaskGenerateStructureWithOutParameters(); String task = "generateDrivenAdapter"; String valueDrivenAdapter = "ASYNCEVENTBUS"; runner.withArguments(task, "--type=" + valueDrivenAdapter); runner.withProjectDir(projectDir); BuildResult result = runner.build(); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/build.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/async-event-bus/src/main/java/co/com/bancolombia/event/ReactiveEventsGateway.java").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/bancolombia/model/event/gateways/EventsGateway.java").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #8
Source File: EndpointsCombinedPluginTest.java From endpoints-framework-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testClientServerIntegrationBuilds() throws IOException, URISyntaxException { BuildResult buildResult = new TestProject(testProjectDir.getRoot(), "projects/clientserver") .gradleRunnerArguments("assemble") .build(); // Part of what we're testing is that a class with a dependency on generated source will compile // correctly when the generated source is created at build time. The above build will fail with // a gradle exception if generation and association of the generated source with the project // does not happen correctly. File genSrcDir = new File(testProjectDir.getRoot(), "client/build/endpointsGenSrc"); File genSrcFile = new File(genSrcDir, "com/example/testApi/TestApi.java"); Assert.assertTrue(genSrcFile.exists()); }
Example #9
Source File: SourceContextPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testCreateSourceContextViaAssemble_taskTree() throws IOException { setUpTestProject(); BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("assemble", "--dry-run") .build(); final List<String> expected = Arrays.asList( ":_createSourceContext", ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble"); Assert.assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #10
Source File: IntegrationTest.java From jig with Apache License 2.0 | 6 votes |
@ParameterizedTest @EnumSource(GradleVersions.class) void スタブプロジェクトのcleanタスクで出力ディレクトリが中のファイルごと削除されること(GradleVersions version) throws IOException, URISyntaxException { Files.createDirectories(outputDir); Path includedFile = outputDir.resolve("somme.txt"); Files.createFile(includedFile); SoftAssertions softly = new SoftAssertions(); softly.assertThat(outputDir).exists(); softly.assertThat(includedFile).exists(); softly.assertAll(); BuildResult result = runner.executeGradleTasks(version, "clean"); softly.assertThat(result.getOutput()).contains("BUILD SUCCESSFUL"); softly.assertThat(includedFile).doesNotExist(); softly.assertThat(outputDir).doesNotExist(); softly.assertAll(); }
Example #11
Source File: EndpointProxiesGenTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
@Test public void testJavaDefault() throws IOException { initTestEnv(); StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n") .append("task generateTestProxy(type: com.marklogic.client.tools.gradle.EndpointProxiesGenTask) {\n") .append(" serviceDeclarationFile = '"+testEnv.serviceDir.getPath()+"/service.json'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments("generateTestProxy") .withDebug(true) .build(); assertTrue("buildscript did not generate "+testEnv.outClass.getPath(), testEnv.outClass.exists()); testEnv.buildFile.delete(); testEnv.outClass.delete(); }
Example #12
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testOffline_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineStage", "--dry-run", "--offline"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", // ":downloadCloudSdk", this is not included because --offline ":appengineStage"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #13
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testCheck_taskTree() throws IOException { BuildResult buildResult = createTestProjectWithHome().applyGradleRunner("appengineDeploy", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", ":checkCloudSdk", ":appengineStage", ":appengineDeploy"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #14
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testStart_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineStart", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", ":downloadCloudSdk", ":appengineStart"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #15
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testRun_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineRun", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", ":downloadCloudSdk", ":appengineRun"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #16
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeployIndex_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineDeployIndex", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", ":downloadCloudSdk", ":appengineStage", ":appengineDeployIndex"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #17
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeployDispatch_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineDeployDispatch", "--dry-run"); final List<String> expected = ImmutableList.of( ":compileJava", ":processResources", ":classes", ":war", ":explodeWar", ":assemble", ":downloadCloudSdk", ":appengineStage", ":appengineDeployDispatch"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #18
Source File: EndpointProxiesGenTaskTest.java From java-client-api with Apache License 2.0 | 6 votes |
@Test public void testCommandLineInit() throws IOException { initTestEnv(); StringBuilder buildText = new StringBuilder() .append("plugins {\n") .append(" id 'com.marklogic.ml-development-tools'\n") .append("}\n"); writeBuildFile(buildText); BuildResult result = GradleRunner .create() .withProjectDir(testDir.getRoot()) .withPluginClasspath() .withArguments( "-PserviceDeclarationFile="+testEnv.serviceDir.getPath()+"/service.json", "-PjavaBaseDirectory="+testEnv.javaBaseDir.getPath(), "generateEndpointProxies" ) .withDebug(true) .build(); assertTrue("command line did not generate "+testEnv.outClass.getPath(), testEnv.outClass.exists()); testEnv.buildFile.delete(); testEnv.outClass.delete(); }
Example #19
Source File: AppEngineStandardPluginIntegrationTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeploy() throws CloudSdkNotFoundException, IOException, ProcessHandlerException, UnsupportedOsException { BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("appengineDeploy", "--stacktrace") .build(); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Deployed service [standard-project]")); deleteProject(); }
Example #20
Source File: SingleReportTest.java From allure-gradle with Apache License 2.0 | 6 votes |
@Test public void shouldGenerateAllureReport() { BuildResult buildResult = gradleRunner.getBuildResult(); File resultsDir = new File(gradleRunner.getProjectDir(), "build/allure-results"); assertThat(buildResult.getTasks()).as("Download allure task status") .filteredOn(task -> task.getPath().equals(":downloadAllure")) .extracting("outcome") .containsExactly(SUCCESS); assertThat(resultsDir.listFiles()).as("Allure executor info") .filteredOn(file -> file.getName().endsWith("executor.json")) .hasSize(1); File projectDir = gradleRunner.getProjectDir(); File reportDir = new File(projectDir, "build/reports/allure-report"); assertThat(reportDir).as("Allure report directory") .exists(); File testCasesDir = new File(reportDir, "data/test-cases"); assertThat(testCasesDir.listFiles()).as("Allure test cases directory") .isNotEmpty(); }
Example #21
Source File: AppEngineStandardPluginIntegrationTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDeployAll() throws CloudSdkNotFoundException, UnsupportedOsException, IOException, ProcessHandlerException { BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("appengineDeployAll") .build(); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Deployed service [standard-project]")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Custom routings have been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("DoS protection has been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Indexes are being rebuilt. This may take a moment.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Cron jobs have been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Task queues have been updated.")); deleteProject(); }
Example #22
Source File: ReportTaskTest.java From lightning with MIT License | 5 votes |
@Test public void runReportWithMissingInput() { BuildResult result = GradleRunner.create() .withProjectDir(new File("src/integrationTest/resources/build/no/csv")) .withArguments(":report") .withPluginClasspath() .buildAndFail(); assertThat(taskOutputContainsText("Not all mandatory input specified for this task or specified files not readable", result), is(true)); }
Example #23
Source File: WarOverlayPluginTest.java From gradle-plugins with MIT License | 5 votes |
@Test public void testAttatchClassesMaven() throws IOException { loadBuildFileFromClasspath("war-overlay-ac-m.gradle"); BuildResult result = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withArguments("assemble") .withPluginClasspath() .build(); assertThat(result.task(":assemble").getOutcome()).isEqualTo(SUCCESS); assertThat(result.task(":jar").getOutcome()).isEqualTo(SUCCESS); assertThat(result.task(":war").getOutcome()).isEqualTo(SUCCESS); }
Example #24
Source File: AppEngineAppYamlPluginIntegrationTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDeployAll() throws CloudSdkNotFoundException, IOException, ProcessHandlerException, UnsupportedOsException { BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("appengineDeployAll") .build(); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Deployed service [appyaml-project]")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Custom routings have been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("DoS protection has been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Indexes are being rebuilt. This may take a moment.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Cron jobs have been updated.")); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Task queues have been updated.")); deleteProject(); }
Example #25
Source File: PluginCleanFunctionalTest.java From scaffold-clean-architecture with MIT License | 5 votes |
@Test public void canRunTaskGenerateStructureWithParameters() { String task = "cleanArchitecture"; String packageName = "co.com.test"; String projectName = "ProjectName"; runner.withArguments(task, "--name=" + projectName, "--package=" + packageName); runner.withProjectDir(projectDir); BuildResult result = runner.build(); // Verify the result assertTrue(new File("build/functionalTest/README.md").exists()); assertTrue(new File("build/functionalTest/.gitignore").exists()); assertTrue(new File("build/functionalTest/build.gradle").exists()); assertTrue(new File("build/functionalTest/lombok.config").exists()); assertTrue(new File("build/functionalTest/main.gradle").exists()); assertTrue(new File("build/functionalTest/settings.gradle").exists()); assertTrue(new File("build/functionalTest/infrastructure/driven-adapters/").exists()); assertTrue(new File("build/functionalTest/infrastructure/entry-points").exists()); assertTrue(new File("build/functionalTest/infrastructure/helpers").exists()); assertTrue(new File("build/functionalTest/domain/model/src/main/java/co/com/test/model").exists()); assertTrue(new File("build/functionalTest/domain/model/src/test/java/co/com/test/model").exists()); assertTrue(new File("build/functionalTest/domain/model/build.gradle").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/main/java/co/com/test/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/src/test/java/co/com/test/usecase").exists()); assertTrue(new File("build/functionalTest/domain/usecase/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/build.gradle").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/test/MainApplication.java").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/java/co/com/test/config").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/application.yaml").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/main/resources/log4j2.properties").exists()); assertTrue(new File("build/functionalTest/applications/app-service/src/test/java/co/com/test").exists()); assertEquals(result.task(":" + task).getOutcome(), TaskOutcome.SUCCESS); }
Example #26
Source File: AppEngineStandardPluginTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testLogin_taskTree() throws IOException { BuildResult buildResult = createTestProject().applyGradleRunner("appengineCloudSdkLogin", "--dry-run"); final List<String> expected = ImmutableList.of(":downloadCloudSdk", ":appengineCloudSdkLogin"); assertEquals(expected, BuildResultFilter.extractTasks(buildResult)); }
Example #27
Source File: VerifyTaskTest.java From lightning with MIT License | 5 votes |
@Test public void runVerifyWithRegexp() { BuildResult result = GradleRunner.create() .withProjectDir(new File("src/integrationTest/resources/build/regexp")) .withArguments(":verify") .withPluginClasspath() .build(); assertThat(result.task(":verify").getOutcome(), is(SUCCESS)); assertThat(taskOutputContainsFileContent("/results/expected/regexp.txt", result), is(true)); }
Example #28
Source File: GradleCompatibilityTest.java From lightning with MIT License | 5 votes |
@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)); }
Example #29
Source File: WarOverlayPluginTest.java From gradle-plugins with MIT License | 5 votes |
@Test public void testAttatchClassesMaven() throws IOException { loadBuildFileFromClasspath("war-overlay-ac-m.gradle"); BuildResult result = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withArguments("assemble") .withPluginClasspath() .build(); assertThat(result.task(":assemble").getOutcome()).isEqualTo(SUCCESS); assertThat(result.task(":jar").getOutcome()).isEqualTo(SUCCESS); assertThat(result.task(":war").getOutcome()).isEqualTo(SUCCESS); }
Example #30
Source File: EndpointsServerPluginTest.java From endpoints-framework-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDiscoveryDocs_application() throws IOException, URISyntaxException { BuildResult buildResult = new TestProject(testProjectDir.getRoot(), "projects/server") .applicationId("gradle-test") .gradleRunnerArguments("endpointsDiscoveryDocs") .build(); assertDiscoveryDocGeneration("https://gradle-test.appspot.com/_ah/api", DEFAULT_URL); }