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

Junit report - add required fields #4

Merged
merged 3 commits into from
Jul 23, 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
11 changes: 10 additions & 1 deletion src/it/MINVOKER-196_junit_report_file/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]() != null
assert [email protected]() != null
assert [email protected]() == "1"
assert [email protected]() == "0"
assert [email protected]() == "0"
assert [email protected]() == "0"

assert [email protected]() == "project"
def systemOut = testsuite.testcase.'**'.findAll { node -> node.name() == 'system-out' }.get(0)
Expand All @@ -35,7 +40,11 @@ assert !systemOut.text().isEmpty()
// test on second project
testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project_2.xml" ) )

assert [email protected]() != null
assert [email protected]() != null
assert [email protected]() == "1"
assert [email protected]() == "0"
assert [email protected]() == "0"
assert [email protected]() == "1"

assert [email protected]() == "project_2"
Expand Down
2 changes: 1 addition & 1 deletion src/it/script-verify-xml/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1874,8 +1874,15 @@ private void writeJunitReport( BuildJob buildJob, String safeFileName, Execution
{
File reportFile = new File( reportsDirectory, "TEST-" + safeFileName + ".xml" );
Xpp3Dom testsuite = new Xpp3Dom( "testsuite" );
testsuite.setAttribute( "tests", "1" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds correct... why removing tests number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was moved, together with other attributes - see line 1881

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooops sorry I didn't catch that

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() )
Expand Down
2 changes: 1 addition & 1 deletion src/site/apt/examples/post-build-script.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -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>>>.

+------------------
Expand Down