-
Notifications
You must be signed in to change notification settings - Fork 345
Issue #237 parse flakyFailure and rerunFailure from surefire report files #765
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
Issue #237 parse flakyFailure and rerunFailure from surefire report files #765
Conversation
Signed-off-by: Olivier Lamy <[email protected]>
Signed-off-by: Olivier Lamy <[email protected]>
|
I have only added the datas as I'm not sure how to do this with the UI. |
| private String errorStackTrace; | ||
| private String errorDetails; | ||
| private Map<String, String> properties; | ||
| private FlakyFailure[] flakyFailures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason these are an array rather than a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reasons, using List is creating some empty elements in xml and fail TestResultTest#bigResultReadWrite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you are using records, I think. XStream does not support them well. x-stream/xstream#345 If you switch to final classes (yes it is irritating) then you should be able to make this a List<FlakyFailure> and XStream should produce (semi-)attractive and functional XML.
Just be sure the concrete type is ArrayList! Do not try to use List.of(), Collections.unmodifiableList, etc. in the field itself. You can always clone lists in a getter and/or setter or use an unmodifiable collection in a getter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was more about returning an empty liist which create an empty element in the xml and so was breaking the test TestResultTest#bigResultReadWrite
Now by using List but returning null instead of empty list the test is passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just check the format carefully to make sure the records work here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit test is reading correct values from parsed files.
So I suppose it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah just double-check the XML format on disk by inspection.
Signed-off-by: Olivier Lamy <[email protected]>
Signed-off-by: Olivier Lamy <[email protected]>
Signed-off-by: Olivier Lamy <[email protected]>
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fine as a start, not too useful for most people without the UI but that can be added on top, what do others think?
| this.parent = parent; | ||
| } | ||
|
|
||
| public @CheckForNull List<FlakyFailure> getFlakyFailures() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @CheckForNull is not required now.
I wonder, why the field itself still is nullable? All those ugly if (x != null) guards could be eliminated by working with an empty collection. You can add a readResolve method to ensure that the field is set in old serializations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because this
[ERROR] Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.579 s <<< FAILURE! -- in hudson.tasks.junit.TestResultTest
[ERROR] hudson.tasks.junit.TestResultTest.bigResultReadWrite -- Time elapsed: 0.298 s <<< FAILURE!
org.opentest4j.AssertionFailedError: Forgot to implement XML parsing for something? ==> expected: <true> but was: <false>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:158)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:69)
at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:41)
at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:228)
at hudson.tasks.junit.TestResultTest.bigResultReadWrite(TestResultTest.java:464)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestResultTest.bigResultReadWrite:464 Forgot to implement XML parsing for something? ==> expected: <true> but was: <false>
so it looks parsing files needs to be done with XMLStreamReader as well,
Hopefully I don't have to do with SAX.. (at least I hope :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting test, it is totally unclear what the test is doing. Would be helpful when the variables would use meaningful names...
Without using XmlUnit it is hard too see what is wrong in the document.
|
back to draft to implement all possible xml parsers :) |
|
FYI there seems to be some way to show flakiness as this screenshot has it: #766 |
|
@timja that's this plugin https://plugins.jenkins.io/test-stability/ |
Signed-off-by: Olivier Lamy <[email protected]>
Signed-off-by: Olivier Lamy <[email protected]>
this plugin is not taking into account the fact that surefire may eventually rerun test multiple times before getting a success (which means it's flaky :)) |
uhafner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a maintainer of the plugin so I don't want to create too much overhead for you.
So only a non-binding comment (as another Jenkins plugin developer):
I am wondering why the same code is used for flakyFailures and rerunFailures. Even the entities are identical. Wouldn't it simplify everything when the values are stored in an entity Failure? One is created for the flakyFailures element and one for the rerunFailures element?
Signed-off-by: Olivier Lamy <[email protected]>
Signed-off-by: Olivier Lamy <[email protected]>
|
@uhafner yes good point. I have refactored a bit to simplify. back to record and use a single entity. |
| .getProperties() | ||
| .size()); | ||
|
|
||
| Diff fileDiff = DiffBuilder.compare(f.getFile()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well we can keep to use only the simple String diff option.
but this one gives more details when failing
|
@timja back to review and ready |
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Part of #237
Testing done
Submitter checklist