forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gradle: Support for additional test-to-main directory mappings
* Determine test output directory based on the task * Raise an exception if the mapping data is invalid. * Include a functional-test for verifying the plugin behavior
- Loading branch information
Showing
11 changed files
with
182 additions
and
11 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
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
24 changes: 24 additions & 0 deletions
24
integration-tests/gradle/src/test/java/io/quarkus/gradle/AdditionalSourceSetsTest.java
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,24 @@ | ||
package io.quarkus.gradle; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test for verifying that the plugin can work with test-sources which are included as part of a custom source set. | ||
* E.g., functional-tests / integration-tests. | ||
*/ | ||
public class AdditionalSourceSetsTest extends QuarkusGradleWrapperTestBase { | ||
|
||
@Test | ||
public void executeFunctionalTest() throws URISyntaxException, IOException, InterruptedException { | ||
final File projectDir = getProjectDir("additional-source-sets"); | ||
BuildResult result = runGradleWrapper(projectDir, "functionalTest"); | ||
assertEquals(BuildResult.SUCCESS_OUTCOME, result.getTasks().get(":functionalTest"), | ||
"Failed to run tests defined in an alternate test sources directory"); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
integration-tests/gradle/src/test/resources/additional-source-sets/build.gradle
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,50 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
implementation "io.quarkus:quarkus-arc" | ||
testImplementation "io.quarkus:quarkus-junit5" | ||
} | ||
|
||
sourceSets { | ||
// Functional Tests | ||
funcTest { | ||
java.srcDir 'src/funcTest/java' | ||
if (file('src/funcTest/resources').exists()) { | ||
resources.srcDir 'src/funcTest/resources' | ||
} | ||
|
||
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath + configurations.compileOnly | ||
runtimeClasspath += output + compileClasspath | ||
} | ||
} | ||
|
||
compileJava { | ||
options.compilerArgs << '-parameters' | ||
} | ||
|
||
/* | ||
* Functional tests for this module. | ||
*/ | ||
task functionalTest(type: Test, description: 'Functional tests', dependsOn: [processResources, classes]) { | ||
description = 'Run the functional tests.' | ||
group = 'verification' | ||
|
||
useJUnitPlatform() | ||
testClassesDirs = sourceSets.funcTest.output.classesDirs | ||
classpath = sourceSets.funcTest.runtimeClasspath | ||
|
||
// Show standard streams on the console. | ||
testLogging { | ||
showStandardStreams = true | ||
} | ||
systemProperty 'quarkus.http.host', 'localhost' | ||
} |
2 changes: 2 additions & 0 deletions
2
integration-tests/gradle/src/test/resources/additional-source-sets/gradle.properties
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,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
12 changes: 12 additions & 0 deletions
12
integration-tests/gradle/src/test/resources/additional-source-sets/settings.gradle
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,12 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
rootProject.name = 'additional-test-sources' |
19 changes: 19 additions & 0 deletions
19
...gradle/src/test/resources/additional-source-sets/src/funcTest/java/ft/SimpleBeanTest.java
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,19 @@ | ||
package ft; | ||
|
||
import javax.inject.Inject; | ||
import org.junit.jupiter.api.Test; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@QuarkusTest | ||
public class SimpleBeanTest { | ||
|
||
@Inject | ||
SimpleBean bean; | ||
|
||
@Test | ||
public void verify() { | ||
assertEquals("hello", bean.hello(), "Did the implementation of the SimpleBean change?"); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...n-tests/gradle/src/test/resources/additional-source-sets/src/main/java/ft/SimpleBean.java
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,11 @@ | ||
package ft; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class SimpleBean { | ||
|
||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ts/gradle/src/test/resources/additional-source-sets/src/main/resources/META-INF/beans.xml
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" | ||
bean-discovery-mode="all"> | ||
</beans> |
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