Skip to content

Commit 1ab4140

Browse files
authored
[MINVOKER-196] Support for JUnit report style (#3)
* [MINVOKER-196] Support for JUnit report style Signed-off-by: olivier lamy <[email protected]>
1 parent 0dc063a commit 1ab4140

File tree

14 files changed

+435
-17
lines changed

14 files changed

+435
-17
lines changed

pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ under the License.
315315
<plugin>
316316
<groupId>org.apache.maven.plugins</groupId>
317317
<artifactId>maven-invoker-plugin</artifactId>
318-
<version>3.1.0</version>
318+
<version>3.2.0</version>
319319
<configuration>
320320
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
321321
<preBuildHookScript>setup</preBuildHookScript>
@@ -371,6 +371,9 @@ under the License.
371371
<groupId>org.apache.maven.plugins</groupId>
372372
<artifactId>maven-invoker-plugin</artifactId>
373373
<version>${project.version}</version>
374+
<configuration>
375+
<writeJunitReport>true</writeJunitReport>
376+
</configuration>
374377
</plugin>
375378
</plugins>
376379
</pluginManagement>

src/it/MINVOKER-191/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ under the License.
6666
<artifactId>maven-invoker-plugin</artifactId>
6767
<version>@project.version@</version>
6868
<configuration>
69+
<writeJunitReport>true</writeJunitReport>
6970
<properties>
7071
<!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central -->
7172
<https.protocols>${https.protocols}</https.protocols>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.plugins.invoker</groupId>
26+
<artifactId>junit-report-file</artifactId>
27+
<version>1.0-SNAPSHOT</version>
28+
<packaging>jar</packaging>
29+
30+
<description>
31+
Test to check for proper generation of junit report files
32+
</description>
33+
34+
<properties>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
</properties>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<!-- This triggers the download of a known version of this plugin which can then be safely invoked by the IT project -->
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-resources-plugin</artifactId>
44+
<version>2.2</version>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-invoker-plugin</artifactId>
49+
<version>@pom.version@</version>
50+
<configuration>
51+
<ignoreFailures>true</ignoreFailures>
52+
<writeJunitReport>true</writeJunitReport>
53+
<postBuildHookScript>verify</postBuildHookScript>
54+
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
55+
<settingsFile>src/it/settings.xml</settingsFile>
56+
<goals>
57+
<goal>validate</goal>
58+
</goals>
59+
</configuration>
60+
<executions>
61+
<execution>
62+
<id>integration-test</id>
63+
<phase>initialize</phase>
64+
<goals>
65+
<goal>run</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
73+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<groupId>test</groupId>
25+
<artifactId>test-junit-report</artifactId>
26+
<version>0.1-SNAPSHOT</version>
27+
<packaging>jar</packaging>
28+
29+
<properties>
30+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31+
</properties>
32+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
// ensure script context contains localRepositoryPath
21+
assert new File( basedir, "../../../target/it-repo" ).canonicalFile.equals( localRepositoryPath )
22+
23+
File interpolatedSettings = new File( basedir, "../interpolated-settings.xml" )
24+
assert interpolatedSettings.isFile()
25+
26+
def filename = new File( basedir, "../../../../../local-repo" ).canonicalPath
27+
// Convert URL, see org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(String)
28+
String url = "file://" + new File( filename ).toURI().path
29+
if ( url.endsWith( "/" ) )
30+
{
31+
url = url.substring( 0, url.length() - 1 )
32+
}
33+
34+
def settings = new XmlSlurper().parse( interpolatedSettings )
35+
36+
// ensure right settings and mirror are picked up
37+
def sandboxMirror = settings.mirrors.mirror[0]
38+
assert sandboxMirror.id.text() == "sandbox"
39+
assert sandboxMirror.url.text() != "@localRepositoryUrl@"
40+
41+
// sandboxMirror.url is NOT filled with localRepositoryPath, but with the localRepository of the parent Settings
42+
assert sandboxMirror.url.text() == url
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<groupId>test</groupId>
25+
<artifactId>pom-filtering-junit-report</artifactId>
26+
<version>0.1-SNAPSHOT</version>
27+
<packaging>jar</packaging>
28+
29+
<properties>
30+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31+
<!-- ${...} must be left unfiltered -->
32+
<prop0>${project.version}</prop0>
33+
<!-- these must be filtered -->
34+
<prop1>@project.version@</prop1>
35+
<prop2>@propertyFromPluginConfig@</prop2>
36+
<prop3>@propertyFromPropertiesSection@</prop3>
37+
<!-- this must not be resolved to project.version, i.e. the prefix matters -->
38+
<prop4>@project-is-not-the-pom.version@</prop4>
39+
<!-- POM values must precede other properties -->
40+
<prop5>@project.name@</prop5>
41+
<prop6>@pom.name@</prop6>
42+
<!-- properties from the plugin config must precede values from the POM's <properties> section -->
43+
<prop7>@itProperty@</prop7>
44+
<!-- properties with prefix "project"/"pom" must fallback to plugin config if no matching POM value exists -->
45+
<prop8>@project.nonExistingPomValue@</prop8>
46+
<!-- built-in properties must not be overridden by properties from the plugin configuration -->
47+
<prop9>@basedir@</prop9>
48+
<prop10>@baseurl@</prop10>
49+
<prop11>@localRepository@</prop11>
50+
<prop12>@localRepositoryUrl@</prop12>
51+
</properties>
52+
53+
<build>
54+
<!-- using the Resources Plugin to create a backup of the executed POM for later inspection by the parent build -->
55+
<resources>
56+
<resource>
57+
<directory>${basedir}</directory>
58+
<filtering>false</filtering>
59+
<includes>
60+
<include>*.xml</include>
61+
</includes>
62+
</resource>
63+
</resources>
64+
<plugins>
65+
<plugin>
66+
<artifactId>maven-resources-plugin</artifactId>
67+
<version>2.2</version>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
assert new File( basedir, "../../../target/it-repo_not_here" ).canonicalFile.equals( localRepositoryPath )
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<settings>
23+
<mirrors>
24+
<mirror>
25+
<id>sandbox</id>
26+
<name>A completely isolated repo to test the interpolation of "localRepositoryUrl"</name>
27+
<url>@localRepositoryUrl@</url>
28+
<mirrorOf>*</mirrorOf>
29+
</mirror>
30+
</mirrors>
31+
</settings>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
File buildLog = new File( basedir, 'build.log' )
20+
assert buildLog.text.contains( '[INFO] run post-build script verify.groovy' )
21+
22+
File invokerReports = new File( new File(basedir, "target"), 'invoker-reports' )
23+
assert buildLog.exists()
24+
25+
// test on first project
26+
def testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project.xml" ) )
27+
28+
assert testsuite.@tests.text() == "1"
29+
30+
assert testsuite.testcase.@name.text() == "project"
31+
def systemOut = testsuite.testcase.'**'.findAll { node -> node.name() == 'system-out' }.get(0)
32+
assert !systemOut.text().isEmpty()
33+
34+
35+
// test on second project
36+
testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project_2.xml" ) )
37+
38+
assert testsuite.@tests.text() == "1"
39+
assert testsuite.@failures.text() == "1"
40+
41+
assert testsuite.testcase.@name.text() == "project_2"
42+
def failureMessage = testsuite.testcase.failure.@message
43+
assert !failureMessage.text().isEmpty()

src/it/fail-build/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ under the License.
4040
<artifactId>maven-invoker-plugin</artifactId>
4141
<version>@pom.version@</version>
4242
<configuration>
43+
<writeJunitReport>true</writeJunitReport>
4344
<debug>true</debug>
4445
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
4546
<pomIncludes>

0 commit comments

Comments
 (0)