From 56d71eb8f1816cab8f2e32399d8ab92c8666f2e8 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 21 Oct 2024 15:26:37 +0900 Subject: [PATCH] Added a sample Maven project to generate junit report xml --- sample-maven/README.md | 2 + sample-maven/pom.xml | 90 +++++++++++++++++++ sample-maven/src/main/java/test/App.java | 10 +++ sample-maven/src/test/java/test/AppTest.java | 35 ++++++++ .../src/test/java/test/sub/AnotherTest.java | 11 +++ 5 files changed, 148 insertions(+) create mode 100644 sample-maven/README.md create mode 100644 sample-maven/pom.xml create mode 100644 sample-maven/src/main/java/test/App.java create mode 100644 sample-maven/src/test/java/test/AppTest.java create mode 100644 sample-maven/src/test/java/test/sub/AnotherTest.java diff --git a/sample-maven/README.md b/sample-maven/README.md new file mode 100644 index 0000000..5d06ec7 --- /dev/null +++ b/sample-maven/README.md @@ -0,0 +1,2 @@ +Sample Maven project that can be used to generate junitReport.xml +that has various interesting ingredients. diff --git a/sample-maven/pom.xml b/sample-maven/pom.xml new file mode 100644 index 0000000..0972196 --- /dev/null +++ b/sample-maven/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + test + sample-maven + 1.0-SNAPSHOT + + sample-maven + + http://www.example.com + + + UTF-8 + 11 + + + + + + org.junit + junit-bom + 5.11.0 + pom + import + + + + + + + org.junit.jupiter + junit-jupiter-api + test + + + + org.junit.jupiter + junit-jupiter-params + test + + + + + + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + maven-site-plugin + 3.12.1 + + + maven-project-info-reports-plugin + 3.6.1 + + + + + diff --git a/sample-maven/src/main/java/test/App.java b/sample-maven/src/main/java/test/App.java new file mode 100644 index 0000000..e569eb5 --- /dev/null +++ b/sample-maven/src/main/java/test/App.java @@ -0,0 +1,10 @@ +package test; + +/** + * Hello world! + */ +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/sample-maven/src/test/java/test/AppTest.java b/sample-maven/src/test/java/test/AppTest.java new file mode 100644 index 0000000..cb35385 --- /dev/null +++ b/sample-maven/src/test/java/test/AppTest.java @@ -0,0 +1,35 @@ +package test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + + /** + * Rigorous Test :-) + */ + @Test + public void shouldAnswerWithTrue() { + assertTrue(true); + } + + @Test + public void failingTest() { + System.err.println("stderr output"); + assertTrue(false); + } + + @Test + public void errorTest() { + System.out.println("stdout output"); + throw new IllegalArgumentException("Some unexpected error"); + } + + @Disabled + public void ignoredTest() {} +} diff --git a/sample-maven/src/test/java/test/sub/AnotherTest.java b/sample-maven/src/test/java/test/sub/AnotherTest.java new file mode 100644 index 0000000..a947303 --- /dev/null +++ b/sample-maven/src/test/java/test/sub/AnotherTest.java @@ -0,0 +1,11 @@ +package test.sub; + +import org.junit.jupiter.api.Test; + +public class AnotherTest { + @Test + public void foo() {} + + @Test + public void bar() {} +}