junitxml classname="" for additional test paths on command line
See original GitHub issueWe are running pytest with the following invocation:
pytest` ".\first_project\tests" ".\second_project\tests" --junitxml=test_results.xml
To discover and run tests in two folders and compile the results in one test_results.xml folder.
Tests written as single functions in the first folder are listed appropriately in the test_results.xml file with the attributes classname="test_example" file="test_example.py"
. Results from tests written as simple functions in the second folder have accurate attributes and elements except for the inferred classname attribute, which is inferred as a blank string classname=""
. The file attribute is also different from the simple filename from the tests discovered in the first folder, but is instead an abreviated full path i.e. file="..\..\first_project\tests\test_example_2.py"
.
Tests that are methods inside of a class in the first folder are given classname="filename.Classname"
. In the second path the results are listed as classname=".Classname"
. So the filename is dropped on the long path here too.
Having test functions return classname=“” for the second path makes some parsing tools choke, like Bamboo’s JUnit Parser.
I’d suggest the test results shouldn’t depend on the order in which the paths were supplied in the command line, perhaps all the tests could have the long version of the file attribute, and that the classname should be inferred from the long attribute appropriately.
pytest version =3.1.3 python version =2.7.12 (Anaconda) Windows 10
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
I am experiencing the same issue with the
classname=""
when running tests that are installed as part of a package, i.e.pip install <package-name>
.pytest
from the project source directory.pytest --pyargs <package-name>
, after installing it in development mode, i.e.pip install -e .
I did a little more debugging, and it looks like the issue stems from how the nodeids are assigned. In the first test case we have the nodeids for the tests:
For the second case the situation is reversed