mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Add Gradle functional tests
Reference: https://guides.gradle.org/testing-gradle-plugins/
This commit is contained in:
@@ -18,12 +18,6 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// Add a source set for the functional test suite
|
||||
sourceSets {
|
||||
functionalTest {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api gradleApi()
|
||||
implementation "io.quarkus:quarkus-bootstrap-core:${version}"
|
||||
@@ -33,7 +27,7 @@ dependencies {
|
||||
implementation "io.quarkus:quarkus-development-mode:${version}"
|
||||
implementation "io.quarkus:quarkus-creator:${version}"
|
||||
|
||||
testImplementation 'org.assertj:assertj-core:3.13.2'
|
||||
testImplementation 'org.assertj:assertj-core:3.14.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.5.2'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
|
||||
@@ -67,5 +61,26 @@ gradlePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
buildScan {
|
||||
// Add a source set for the functional test suite
|
||||
sourceSets {
|
||||
functionalTest {
|
||||
}
|
||||
}
|
||||
|
||||
gradlePlugin.testSourceSets(sourceSets.functionalTest)
|
||||
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)
|
||||
configurations.functionalTestRuntime.extendsFrom(configurations.testRuntimeOnly)
|
||||
|
||||
// Add a task to run the functional tests
|
||||
task functionalTest(type: Test) {
|
||||
description = "Runs functional tests"
|
||||
group = "verification"
|
||||
useJUnitPlatform()
|
||||
testClassesDirs = sourceSets.functionalTest.output.classesDirs
|
||||
classpath = sourceSets.functionalTest.runtimeClasspath
|
||||
}
|
||||
|
||||
check {
|
||||
// Run the functional tests as part of `check`
|
||||
dependsOn(tasks.functionalTest)
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
<gradle.executable>./gradlew</gradle.executable>
|
||||
<gradle.task>build</gradle.task>
|
||||
<skip.gradle.build>false</skip.gradle.build>
|
||||
<maven.install.skip>true</maven.install.skip>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -77,6 +79,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Do not deploy this project-->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>${nexus-staging-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.quarkus.gradle;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.quarkus.cli.commands.CreateProject;
|
||||
import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
import io.quarkus.generators.BuildTool;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.GradleRunner;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class QuarkusPluginFunctionalTest {
|
||||
|
||||
@Test
|
||||
public void canRunListExtensions(@TempDir File projectRoot) throws IOException {
|
||||
assertThat(new CreateProject(new FileProjectWriter(projectRoot))
|
||||
.groupId("com.acme.foo")
|
||||
.artifactId("foo")
|
||||
.version("1.0.0-SNAPSHOT")
|
||||
.buildTool(BuildTool.GRADLE)
|
||||
.doCreateProject(new HashMap<>()))
|
||||
.withFailMessage("Project was not created")
|
||||
.isTrue();
|
||||
|
||||
BuildResult build = GradleRunner.create()
|
||||
.forwardOutput()
|
||||
.withPluginClasspath()
|
||||
.withArguments("listExtensions")
|
||||
.withProjectDir(projectRoot)
|
||||
.build();
|
||||
|
||||
assertThat(build.getOutput()).contains("Quarkus - Core");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user