Skip to content

Commit 56d71eb

Browse files
committed
Added a sample Maven project to generate junit report xml
1 parent c235b0d commit 56d71eb

File tree

5 files changed

+148
-0
lines changed

5 files changed

+148
-0
lines changed

sample-maven/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sample Maven project that can be used to generate junitReport.xml
2+
that has various interesting ingredients.

sample-maven/pom.xml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>test</groupId>
7+
<artifactId>sample-maven</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<name>sample-maven</name>
11+
<!-- FIXME change it to the project's website -->
12+
<url>http://www.example.com</url>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<maven.compiler.release>11</maven.compiler.release>
17+
</properties>
18+
19+
<dependencyManagement>
20+
<dependencies>
21+
<dependency>
22+
<groupId>org.junit</groupId>
23+
<artifactId>junit-bom</artifactId>
24+
<version>5.11.0</version>
25+
<type>pom</type>
26+
<scope>import</scope>
27+
</dependency>
28+
</dependencies>
29+
</dependencyManagement>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.junit.jupiter</groupId>
34+
<artifactId>junit-jupiter-api</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
<!-- Optionally: parameterized tests support -->
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter-params</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
47+
<plugins>
48+
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
49+
<plugin>
50+
<artifactId>maven-clean-plugin</artifactId>
51+
<version>3.4.0</version>
52+
</plugin>
53+
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
54+
<plugin>
55+
<artifactId>maven-resources-plugin</artifactId>
56+
<version>3.3.1</version>
57+
</plugin>
58+
<plugin>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<version>3.13.0</version>
61+
</plugin>
62+
<plugin>
63+
<artifactId>maven-surefire-plugin</artifactId>
64+
<version>3.3.0</version>
65+
</plugin>
66+
<plugin>
67+
<artifactId>maven-jar-plugin</artifactId>
68+
<version>3.4.2</version>
69+
</plugin>
70+
<plugin>
71+
<artifactId>maven-install-plugin</artifactId>
72+
<version>3.1.2</version>
73+
</plugin>
74+
<plugin>
75+
<artifactId>maven-deploy-plugin</artifactId>
76+
<version>3.1.2</version>
77+
</plugin>
78+
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
79+
<plugin>
80+
<artifactId>maven-site-plugin</artifactId>
81+
<version>3.12.1</version>
82+
</plugin>
83+
<plugin>
84+
<artifactId>maven-project-info-reports-plugin</artifactId>
85+
<version>3.6.1</version>
86+
</plugin>
87+
</plugins>
88+
</pluginManagement>
89+
</build>
90+
</project>
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test;
2+
3+
/**
4+
* Hello world!
5+
*/
6+
public class App {
7+
public static void main(String[] args) {
8+
System.out.println("Hello World!");
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package test;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.Test;
7+
8+
/**
9+
* Unit test for simple App.
10+
*/
11+
public class AppTest {
12+
13+
/**
14+
* Rigorous Test :-)
15+
*/
16+
@Test
17+
public void shouldAnswerWithTrue() {
18+
assertTrue(true);
19+
}
20+
21+
@Test
22+
public void failingTest() {
23+
System.err.println("stderr output");
24+
assertTrue(false);
25+
}
26+
27+
@Test
28+
public void errorTest() {
29+
System.out.println("stdout output");
30+
throw new IllegalArgumentException("Some unexpected error");
31+
}
32+
33+
@Disabled
34+
public void ignoredTest() {}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package test.sub;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
public class AnotherTest {
6+
@Test
7+
public void foo() {}
8+
9+
@Test
10+
public void bar() {}
11+
}

0 commit comments

Comments
 (0)