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

Fixed JUnit test-by-config reporting #1160

Closed
wants to merge 4 commits into from

Conversation

bitwiseman
Copy link

Without some way to distinguish between different config runs of the same tests,
Unit reporters will tend to treat multiple results for the same test case of the duplicates.

Jenkins JUnit report will ignore these "duplicates" producing very confusing test results.

The change add a "class path" the results based on configuration and file path. This allows
reporter consumers to process the results correctly as different results instances.

@bitwiseman bitwiseman force-pushed the junit-classname branch 2 times, most recently from 232f542 to 42a945a Compare August 24, 2016 23:22
@bitwiseman
Copy link
Author

Here's what the output on a sample project with 5 tests on 4 configurations does with this change:

screen shot 2016-08-24 at 3 59 15 pm

Before this change the multiple configs are treated as one config. After they are seent as separate results.

@bitwiseman bitwiseman changed the title Fixed JUnit tests by config reporting Fixed JUnit test-by-config reporting Aug 25, 2016
@bitwiseman
Copy link
Author

@beatfactor - Should I go back and file an issue for this or can we go with just the pull request?

@beatfactor
Copy link
Member

For now it's ok, but maybe in the future, it would be appreciated.

@bitwiseman
Copy link
Author

@beatfactor - if you'd like I can add a few tests for file content to make sure it includes the classname in future. I won't get to it for a couple days though.

@beatfactor
Copy link
Member

Sure, tests are always welcome.

@bitwiseman
Copy link
Author

@beatfactor - okay, added content tests.

@drptbl
Copy link

drptbl commented Sep 4, 2016

@bitwiseman
Using Jenkins 2.7.3 (LTS + freestyle project), this pull request breaks parsing (or creation, didn't test it further) of JUnit reports.

15:31:51 ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?

@bitwiseman
Copy link
Author

@drptbl - It changes the file path that the file are written to. Check the glob pattern you're using for finding the files. Make sure it is something like <outputpath>/**/*.xml.

@drptbl
Copy link

drptbl commented Sep 4, 2016

@bitwiseman Sorry, I wasn't aware of that, will do further testing. Is JUnit reports file path change needed and intended? It will break most Jenkins builds after merge to master.

@bitwiseman
Copy link
Author

@beatfactor @drptbl
It was intentional, and I would argue needed. It still obeys the output directory, it just adds one more level to the tree by putting the config string on the front.

see https://github.com/nightwatchjs/nightwatch/pull/1160/files#diff-11f6da1d76940abb03b522fcd51edb9fR112

I would argue that Nightwatch already makes an arbitrary depth tree for output files, so one more level that adds clarity is a good thing, and patterns that look for these files should already be loading that full tree (via ** glob). However, I'm fine doing something else too.

@beatfactor
Copy link
Member

Maybe we should just add the classname attribute for now. Would that make any difference?

@bitwiseman
Copy link
Author

Okay, I removed the file path change. It there is still a change to the module name inside the file but that is required as before the module name wasn't including the configuration.

@bitwiseman
Copy link
Author

@beatfactor - I think this is all set.

@@ -56,6 +56,22 @@ module.exports = new (function() {

adaptAssertions(module);

var filename = moduleName + '.xml';
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really in favour of this change, I don't think it's necessary and the potential impact is unknown. I'd rather just stick to the classname attribute change without anymore changes.

Copy link
Author

@bitwiseman bitwiseman Sep 15, 2016

Choose a reason for hiding this comment

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

I'm going to redo this with tests that verify the current output and then test the change.
I'm going to follow the template of https://github.com/karma-runner/karma-junit-reporter

@bitwiseman
Copy link
Author

@beatfactor
I've went back and changed this to three commits.
The first adds tests for the existing content.
The second is a pure refactor (which the tests guarantee is non-breaking).
The third is the actual change, which I've re-done to only add the classpath (and the tests show that the classpath is the only change to the output).

Thanks for your patience though these multiple iterations.

@bitwiseman
Copy link
Author

@beatfactor - It is not clear to me what check failed. The build reported success and then the process in travis exited 1.

@beatfactor
Copy link
Member

jshint validation failed.

@bitwiseman
Copy link
Author

bitwiseman commented Sep 15, 2016

@beatfactor - Ah, okay, fixed.

@bitwiseman
Copy link
Author

@beatfactor ? Ping?

@bitwiseman
Copy link
Author

@beatfactor - Is there anything else for me to do here?

@bitwiseman
Copy link
Author

@beatfactor - I've made the changes your requested and all tests are passing. Can we merge?

@bitwiseman
Copy link
Author

@beatfactor - Hello? Are you there?

Preparing for adding classname to junit file
Without some way to distinguish between different config runs of the same tests,
Unit reporters will tend to treat multiple results for the same test case of the duplicates.

Jenkins JUnit report will ignore these "duplicates" producing very confusing test results.

The change add a "class path" the results based on configuration and file path. This allows
reporter consumers to process the results correctly as different results instances.
The combination of testsuite name and package must be unique in
the case of multiple junit files or reporting systems may ignore later
occurrences as duplicates.

It turns out that the testsuite name should be the full class name anyway.
https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd#L157
@bitwiseman
Copy link
Author

@beatfactor - Rebased on HEAD and added one more changed based on feedback from @jk171505.

@jk171505
Copy link

jk171505 commented Jan 4, 2017

@beatfactor, this feature seems to be crucial when testing multi envs, is there a chance to merge it into master?

@beatfactor
Copy link
Member

Sorry for the delay, I'll look into it in the next few days.

@bitwiseman
Copy link
Author

@beatfactor - I totally understand getting busy and not having time to review. Whenever you get the chance.

@bitwiseman
Copy link
Author

@beatfactor - Ping?

@beatfactor
Copy link
Member

Added classname attribute in v0.9.13

@beatfactor beatfactor closed this Mar 11, 2017
saschagehlich pushed a commit to saschagehlich/nightwatch that referenced this pull request May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants