Skip to content

Commit 05d7e00

Browse files
committed
Add tests for integration test support
1 parent e725ce6 commit 05d7e00

File tree

5 files changed

+54
-80
lines changed

5 files changed

+54
-80
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.graalvm.buildtools.maven;
2+
3+
class IntegrationTest extends AbstractGraalVMMavenFunctionalTest {
4+
def "run integration tests with failsafe plugin"() {
5+
withSample("integration-test")
6+
7+
when:
8+
mvn'-Pnative', 'verify'
9+
10+
then:
11+
buildSucceeded
12+
file("target/failsafe-reports").exists()
13+
file("target/failsafe-reports/org.graalvm.demo.CalculatorTestIT.txt").readLines().any(line -> line.contains("Tests run: 6, Failures: 0, Errors: 0, Skipped: 0"))
14+
outputContains "[junit-platform-native] Running in 'test listener' mode"
15+
outputContains """
16+
[ 3 containers found ]
17+
[ 0 containers skipped ]
18+
[ 3 containers started ]
19+
[ 0 containers aborted ]
20+
[ 3 containers successful ]
21+
[ 0 containers failed ]
22+
[ 6 tests found ]
23+
[ 0 tests skipped ]
24+
[ 6 tests started ]
25+
[ 0 tests aborted ]
26+
[ 6 tests successful ]
27+
[ 0 tests failed ]
28+
""".trim()
29+
}
30+
}

samples/integration-test/pom.xml

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
66
The Universal Permissive License (UPL), Version 1.0
@@ -54,8 +54,6 @@
5454
<junit.jupiter.version>5.13.0</junit.jupiter.version>
5555
<native.maven.plugin.version>0.11.0-SNAPSHOT</native.maven.plugin.version>
5656
<junit.platform.native.version>0.11.0-SNAPSHOT</junit.platform.native.version>
57-
<imageName>example-app</imageName>
58-
<mainClass>org.graalvm.demo.Application</mainClass>
5957
</properties>
6058

6159
<dependencies>
@@ -85,50 +83,24 @@
8583
</execution>
8684
</executions>
8785
</plugin>
86+
<plugin>
87+
<groupId>org.graalvm.buildtools</groupId>
88+
<artifactId>native-maven-plugin</artifactId>
89+
<version>${native.maven.plugin.version}</version>
90+
<extensions>true</extensions>
91+
<executions>
92+
<execution>
93+
<id>test-native</id>
94+
<goals>
95+
<goal>test</goal>
96+
</goals>
97+
<phase>verify</phase>
98+
</execution>
99+
</executions>
100+
</plugin>
88101
</plugins>
89102
</build>
90103
</profile>
91104
</profiles>
92105

93-
<build>
94-
<plugins>
95-
<plugin>
96-
<groupId>org.apache.maven.plugins</groupId>
97-
<artifactId>maven-surefire-plugin</artifactId>
98-
<version>3.0.0-M5</version>
99-
</plugin>
100-
<plugin>
101-
<groupId>org.apache.maven.plugins</groupId>
102-
<artifactId>maven-failsafe-plugin</artifactId>
103-
<version>3.5.3</version>
104-
</plugin>
105-
<plugin>
106-
<groupId>org.codehaus.mojo</groupId>
107-
<artifactId>exec-maven-plugin</artifactId>
108-
<version>3.0.0</version>
109-
<executions>
110-
<execution>
111-
<id>java</id>
112-
<goals>
113-
<goal>java</goal>
114-
</goals>
115-
<configuration>
116-
<mainClass>${mainClass}</mainClass>
117-
</configuration>
118-
</execution>
119-
<execution>
120-
<id>native</id>
121-
<goals>
122-
<goal>exec</goal>
123-
</goals>
124-
<configuration>
125-
<executable>${project.build.directory}/${imageName}</executable>
126-
<workingDirectory>${project.build.directory}</workingDirectory>
127-
</configuration>
128-
</execution>
129-
</executions>
130-
</plugin>
131-
</plugins>
132-
</build>
133-
134106
</project>

samples/integration-test/src/main/java/org/graalvm/demo/Application.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

samples/integration-test/src/main/java/org/graalvm/demo/Calculator.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

samples/integration-test/src/test/java/org/graalvm/demo/CalculatorTestIT.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
import org.junit.jupiter.params.ParameterizedTest;
88
import org.junit.jupiter.params.provider.CsvSource;
99

10-
class CalculatorTest {
10+
class CalculatorTestIT {
11+
12+
private int add(int a, int b) {
13+
return a + b;
14+
}
1115

1216
@Test
1317
@DisplayName("1 + 1 = 2")
1418
void addsTwoNumbers() {
15-
Calculator calculator = new Calculator();
16-
assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
19+
assertEquals(2, add(1, 1), "1 + 1 should equal 2");
1720
}
1821

1922
@Test
2023
@DisplayName("1 + 2 = 3")
2124
void addsTwoNumbers2() {
22-
Calculator calculator = new Calculator();
23-
assertEquals(3, calculator.add(1, 2), "1 + 2 should equal 3");
25+
assertEquals(3, add(1, 2), "1 + 2 should equal 3");
2426
}
2527

2628
@ParameterizedTest(name = "{0} + {1} = {2}")
@@ -31,8 +33,7 @@ void addsTwoNumbers2() {
3133
"1, 100, 101"
3234
})
3335
void add(int first, int second, int expectedResult) {
34-
Calculator calculator = new Calculator();
35-
assertEquals(expectedResult, calculator.add(first, second),
36+
assertEquals(expectedResult, add(first, second),
3637
() -> first + " + " + second + " should equal " + expectedResult);
3738
}
3839
}

0 commit comments

Comments
 (0)