You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2019/07/23 01:15:13 UTC
[maven-invoker-plugin] branch master updated: Junit report - add
required fields (#4)
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 79a84b7 Junit report - add required fields (#4)
79a84b7 is described below
commit 79a84b764f8b5bbbc50a8d019b801ba85fcbf133
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Tue Jul 23 03:15:09 2019 +0200
Junit report - add required fields (#4)
* [MINVOKER-196] add required fields for junit report
Signed-off-by: Slawomir Jaranowski <s....@gmail.com>
---
src/it/MINVOKER-196_junit_report_file/verify.groovy | 11 ++++++++++-
src/it/script-verify-xml/verify.groovy | 2 +-
.../org/apache/maven/plugins/invoker/AbstractInvokerMojo.java | 9 ++++++++-
src/site/apt/examples/post-build-script.apt.vm | 2 +-
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/it/MINVOKER-196_junit_report_file/verify.groovy b/src/it/MINVOKER-196_junit_report_file/verify.groovy
index 5a97c50..331b884 100644
--- a/src/it/MINVOKER-196_junit_report_file/verify.groovy
+++ b/src/it/MINVOKER-196_junit_report_file/verify.groovy
@@ -20,12 +20,17 @@ 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()
+assert invokerReports.exists()
// test on first project
def testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project.xml" ) )
+assert testsuite.@name.text() != null
+assert testsuite.@time.text() != null
assert testsuite.@tests.text() == "1"
+assert testsuite.@errors.text() == "0"
+assert testsuite.@skipped.text() == "0"
+assert testsuite.@failures.text() == "0"
assert testsuite.testcase.@name.text() == "project"
def systemOut = testsuite.testcase.'**'.findAll { node -> node.name() == 'system-out' }.get(0)
@@ -35,7 +40,11 @@ assert !systemOut.text().isEmpty()
// test on second project
testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project_2.xml" ) )
+assert testsuite.@name.text() != null
+assert testsuite.@time.text() != null
assert testsuite.@tests.text() == "1"
+assert testsuite.@errors.text() == "0"
+assert testsuite.@skipped.text() == "0"
assert testsuite.@failures.text() == "1"
assert testsuite.testcase.@name.text() == "project_2"
diff --git a/src/it/script-verify-xml/verify.groovy b/src/it/script-verify-xml/verify.groovy
index d94112b..c1409bf 100644
--- a/src/it/script-verify-xml/verify.groovy
+++ b/src/it/script-verify-xml/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-// from http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper
+// from http://groovy-lang.org/processing-xml.html
// A lot of examples covering xml assertions
class XmlExamples {
diff --git a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
index 730e0dc..a916345 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java
@@ -1874,8 +1874,15 @@ public abstract class AbstractInvokerMojo
{
File reportFile = new File( reportsDirectory, "TEST-" + safeFileName + ".xml" );
Xpp3Dom testsuite = new Xpp3Dom( "testsuite" );
- testsuite.setAttribute( "tests", "1" );
+ testsuite.setAttribute( "name", junitPackageName + "." + safeFileName );
testsuite.setAttribute( "time", Double.toString( buildJob.getTime() ) );
+
+ // set default value for required attributes
+ testsuite.setAttribute( "tests", "1" );
+ testsuite.setAttribute( "errors", "0" );
+ testsuite.setAttribute( "skipped", "0" );
+ testsuite.setAttribute( "failures", "0" );
+
Xpp3Dom testcase = new Xpp3Dom( "testcase" );
testsuite.addChild( testcase );
switch ( buildJob.getResult() )
diff --git a/src/site/apt/examples/post-build-script.apt.vm b/src/site/apt/examples/post-build-script.apt.vm
index 9b871cb..a58bda5 100644
--- a/src/site/apt/examples/post-build-script.apt.vm
+++ b/src/site/apt/examples/post-build-script.apt.vm
@@ -29,7 +29,7 @@
Using a Post-Build Script
Here is an example of how the Invoker Plugin can be used to run a set of Maven projects and then verify their output
- with a {{{http://www.beanshell.org/}BeanShell}} or {{{http://groovy.codehaus.org/}Groovy}} script. The name of the
+ with a {{{http://www.beanshell.org/}BeanShell}} or {{{http://groovy-lang.org/}Groovy}} script. The name of the
script file in this case is <<<verify.bsh>>>.
+------------------