-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from martinbonnin/add-plugin-tests
Add a simple plugin test
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.yelp.plugin | ||
|
||
import org.gradle.testkit.runner.BuildResult | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import java.io.File | ||
|
||
|
||
class PluginTests { | ||
@Test | ||
fun basicPluginTest() { | ||
val tmpDir = File(".", "build/testProject") | ||
tmpDir.deleteRecursively() | ||
|
||
println(File(".").absolutePath) | ||
File(".", "src/test/testProject").copyRecursively(tmpDir) | ||
|
||
val result = GradleRunner.create().withProjectDir(tmpDir) | ||
.forwardStdOutput(System.out.writer()) | ||
.forwardStdError(System.err.writer()) | ||
.withArguments("generateSwagger") | ||
.build() | ||
|
||
Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateSwagger")?.outcome) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import com.yelp.codegen.plugin.GenerateTaskConfiguration | ||
|
||
buildscript { | ||
repositories { | ||
maven { | ||
url = uri("../../../build/localMaven") | ||
} | ||
jcenter { | ||
content { | ||
excludeGroup("com.yelp.codegen") | ||
} | ||
} | ||
} | ||
dependencies { | ||
// Always take the latest version from the local test repo | ||
// This is not super robust and we could find a way to communicate the version to the testProject | ||
// by copying the root buildSrc to the testProject or extracting the version in a properties file | ||
classpath("com.yelp.codegen:plugin:+") | ||
} | ||
} | ||
|
||
apply(plugin = "com.yelp.codegen.plugin") | ||
|
||
configure<GenerateTaskConfiguration> { | ||
platform = "kotlin" | ||
packageName = "com.yelp.codegen.samples" | ||
// this file is in rootDir/plugin/build/testProject/ | ||
inputFile = file("../../../samples/junit-tests/junit_tests_specs.json") | ||
outputDir = file("./build/generatedSources") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name="testProject" |