-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add TestRun, TestRunGroup and JUnit parser classes #318
Conversation
Codecov Report
@@ Coverage Diff @@
## main #318 +/- ##
==========================================
- Coverage 95.55% 95.53% -0.02%
==========================================
Files 79 82 +3
Lines 2745 2800 +55
==========================================
+ Hits 2623 2675 +52
- Misses 122 125 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
129d85a
to
9d0f748
Compare
codecov_cli/parsers/base.py
Outdated
class Test(object): | ||
def __init__(self, name: str, status: bool, duration: timedelta): | ||
self.name = name | ||
self.status = status |
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 status
should be an Enum rather than a bool.
Or change it to "passed" or "successful"
codecov_cli/parsers/base.py
Outdated
skipped: int, | ||
total: int, | ||
): | ||
self.testcases = testcases or [] |
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.
If you don't specify a default value for test cases (e.g. testcases: List[Test] = None
then it can't ever be None
, right?
(if it can then the type hint should be Optional
)
|
||
def _create_testcase(self, testcase_xml: etree.Element): | ||
return Test( | ||
f"{testcase_xml.get('classname')}.{testcase_xml.get('name')}", |
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.
Can this be transformed in the format that we use for labels?
That is path/to/test.py::TestClassIfAny::test_function_name
.
It would be helpful to use this in an ATS setting to have the test names follow this format.
codecov_cli/parsers/junit.py
Outdated
if processed is None or len(processed) == 0: | ||
raise ParsingError("Error parsing XML file") | ||
|
||
testsuites = [ |
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.
You are calling this testsuites
but the type name is TestRun
. I think you should pick one and stick to it. Whatever makes the most sense in the context.
codecov_cli/parsers/base.py
Outdated
self.skipped = skipped | ||
self.total = total | ||
|
||
def to_str(self): |
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 uploader uploads JSON data... maybe we should have the encoding/decoding be to JSON?
If this is for debug purposes (e.g. printing the class nicely into console) than I believe the right function to override is __repr__
.
codecov_cli/parsers/base.py
Outdated
self.duration = duration | ||
|
||
def __repr__(self): | ||
return f"{self.name}:{self.status}:{self.duration.total_seconds()}::" |
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.
Is this to be used as the encoding/decoding or just debugging?
If just for debugging than it's very confusing.
If it's for the encoding/decoding I think it's ok to use JSON directly.
I understand that the payload will be larger, but we compress it before uploading. And making the data easier to understand and work with seems more relevant... I could be wrong, if you have data backing up the fact that unless we encode the data in this compact way the resulting payload will be huge.
Signed-off-by: joseph-sentry <[email protected]>
Signed-off-by: joseph-sentry <[email protected]>
Signed-off-by: joseph-sentry <[email protected]>
Signed-off-by: joseph-sentry <[email protected]>
9d0f748
to
3a9379b
Compare
Signed-off-by: joseph-sentry <[email protected]>
d835297
to
e5d2823
Compare
So after having done some research the answer to this question is not straightforward. It turns out that the pytest junitxml plugin can generate two different versions of junit report, "xunit1" and "xunit2". The "xunit1" version includes a file with each testcase that is generated in the report which should enable this, but I have not implemented support for this in this PR. The "xunit2" version for which you can find the schema here can support including the file in the |
Signed-off-by: joseph-sentry <[email protected]>
This PR: