Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINVOKER-196] Support for JUnit report style #3

Merged
merged 2 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<preBuildHookScript>setup</preBuildHookScript>
Expand Down Expand Up @@ -371,6 +371,9 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
1 change: 1 addition & 0 deletions src/it/MINVOKER-191/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ under the License.
<artifactId>maven-invoker-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
<properties>
<!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central -->
<https.protocols>${https.protocols}</https.protocols>
Expand Down
73 changes: 73 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.invoker</groupId>
<artifactId>junit-report-file</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<description>
Test to check for proper generation of junit report files
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<!-- This triggers the download of a known version of this plugin which can then be safely invoked by the IT project -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<ignoreFailures>true</ignoreFailures>
<writeJunitReport>true</writeJunitReport>
<postBuildHookScript>verify</postBuildHookScript>
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<goals>
<goal>validate</goal>
</goals>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
32 changes: 32 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/src/it/project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test-junit-report</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
42 changes: 42 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/src/it/project/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// ensure script context contains localRepositoryPath
assert new File( basedir, "../../../target/it-repo" ).canonicalFile.equals( localRepositoryPath )

File interpolatedSettings = new File( basedir, "../interpolated-settings.xml" )
assert interpolatedSettings.isFile()

def filename = new File( basedir, "../../../../../local-repo" ).canonicalPath
// Convert URL, see org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(String)
String url = "file://" + new File( filename ).toURI().path
if ( url.endsWith( "/" ) )
{
url = url.substring( 0, url.length() - 1 )
}

def settings = new XmlSlurper().parse( interpolatedSettings )

// ensure right settings and mirror are picked up
def sandboxMirror = settings.mirrors.mirror[0]
assert sandboxMirror.id.text() == "sandbox"
assert sandboxMirror.url.text() != "@localRepositoryUrl@"

// sandboxMirror.url is NOT filled with localRepositoryPath, but with the localRepository of the parent Settings
assert sandboxMirror.url.text() == url
71 changes: 71 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>pom-filtering-junit-report</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- ${...} must be left unfiltered -->
<prop0>${project.version}</prop0>
<!-- these must be filtered -->
<prop1>@project.version@</prop1>
<prop2>@propertyFromPluginConfig@</prop2>
<prop3>@propertyFromPropertiesSection@</prop3>
<!-- this must not be resolved to project.version, i.e. the prefix matters -->
<prop4>@project-is-not-the-pom.version@</prop4>
<!-- POM values must precede other properties -->
<prop5>@project.name@</prop5>
<prop6>@pom.name@</prop6>
<!-- properties from the plugin config must precede values from the POM's <properties> section -->
<prop7>@itProperty@</prop7>
<!-- properties with prefix "project"/"pom" must fallback to plugin config if no matching POM value exists -->
<prop8>@project.nonExistingPomValue@</prop8>
<!-- built-in properties must not be overridden by properties from the plugin configuration -->
<prop9>@basedir@</prop9>
<prop10>@baseurl@</prop10>
<prop11>@localRepository@</prop11>
<prop12>@localRepositoryUrl@</prop12>
</properties>

<build>
<!-- using the Resources Plugin to create a backup of the executed POM for later inspection by the parent build -->
<resources>
<resource>
<directory>${basedir}</directory>
<filtering>false</filtering>
<includes>
<include>*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

assert new File( basedir, "../../../target/it-repo_not_here" ).canonicalFile.equals( localRepositoryPath )
31 changes: 31 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/src/it/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<settings>
<mirrors>
<mirror>
<id>sandbox</id>
<name>A completely isolated repo to test the interpolation of "localRepositoryUrl"</name>
<url>@localRepositoryUrl@</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>
43 changes: 43 additions & 0 deletions src/it/MINVOKER-196_junit_report_file/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( '[INFO] run post-build script verify.groovy' )

File invokerReports = new File( new File(basedir, "target"), 'invoker-reports' )
assert buildLog.exists()

// test on first project
def testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project.xml" ) )

assert [email protected]() == "1"

assert [email protected]() == "project"
def systemOut = testsuite.testcase.'**'.findAll { node -> node.name() == 'system-out' }.get(0)
assert !systemOut.text().isEmpty()


// test on second project
testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project_2.xml" ) )

assert [email protected]() == "1"
assert [email protected]() == "1"

assert [email protected]() == "project_2"
def failureMessage = testsuite.testcase.failure.@message
assert !failureMessage.text().isEmpty()
1 change: 1 addition & 0 deletions src/it/fail-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ under the License.
<artifactId>maven-invoker-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
<debug>true</debug>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<pomIncludes>
Expand Down
1 change: 1 addition & 0 deletions src/it/pom-filtering-reactor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ under the License.
<artifactId>maven-invoker-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
Expand Down
1 change: 1 addition & 0 deletions src/it/script-errors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ under the License.
<artifactId>maven-invoker-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
<cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
Expand Down
1 change: 1 addition & 0 deletions src/it/skip-run/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ under the License.
<artifactId>maven-invoker-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<writeJunitReport>true</writeJunitReport>
<debug>true</debug>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<pomIncludes>
Expand Down
Loading