Skip to content

Commit

Permalink
Improve test-related setup
Browse files Browse the repository at this point in the history
  • Loading branch information
miguno committed May 6, 2024
1 parent fcc9447 commit 825766f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 36 deletions.
19 changes: 13 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ system-info:
@echo "os: {{os()}}"
@echo "os family: {{os_family()}}"

# audit the code
audit:
#!/usr/bin/env bash
echo "Running static code analysis with spotbugs"
just spotbugs
if command -v infer &>/dev/null; then
echo "Running static code analysis with infer"
just infer
fi
# build the native application locally (requires GraalVM)
build-native:
@echo "Producing a native app image via GraalVM ..."
Expand Down Expand Up @@ -58,9 +68,6 @@ clean:
infer:
@infer run -- ./mvnw clean compile

# run integration tests (alias for 'test-integration')
integration-test: test-integration

# package the application to create an uber jar
package:
@./mvnw package
Expand Down Expand Up @@ -105,11 +112,11 @@ spotbugs: compile
test:
@./mvnw test

# run integration tests, including static code analysis with spotbugs
# run integration tests (without unit tests)
test-integration:
@./mvnw integration-test
@./mvnw failsafe:integration-test

# run unit tests and integration tests
# run all tests, plus static code analysis with spotbugs
verify:
@./mvnw verify

Expand Down
62 changes: 33 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.10.0</quarkus.platform.version>
<!-- Test-related settings -->
<skipTests>false</skipTests> <!-- To skip all tests with `-DskipTests` on CLI. -->
<skipITs>${skipTests}</skipITs> <!-- To skip integration tests (failsafe) with `-DskipITs` -->
<skipUTs>${skipTests}</skipUTs> <!-- To skip unit tests (surefire) with `-DskipUTs` (non-standard property) -->
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -100,11 +104,12 @@
</plugin>

<plugin>
<!-- To run unit tests. -->
<!-- To run unit tests. Skip unit tests with `-DskipUTs` on CLI. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>${skipUTs}</skipTests>
<systemPropertyVariables>
<!-- Make sure tests use the correct logmanager. -->
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
Expand All @@ -117,6 +122,33 @@
</configuration>
</plugin>

<plugin>
<!-- To run integration tests. Skip integration tests with `-DskipITs` on CLI. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>${skipTests}</skipTests>
<skipITs>${skipITs}</skipITs>
<systemPropertyVariables>
<!-- Required when building native images, see `<profiles>` below. -->
<native.image.path>
${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
Expand Down Expand Up @@ -237,34 +269,6 @@
<skipITs>false</skipITs>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
<build>
<plugins>
<plugin>
<!-- To run integration tests. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>
${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager
</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.miguno.javadockerbuild;
import io.quarkus.test.junit.QuarkusIntegrationTest;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@QuarkusIntegrationTest
public class StatusResourceIT extends StatusResourceTest { }
public class StatusResourceIT extends StatusResourceTest {}

0 comments on commit 825766f

Please sign in to comment.