https://pantsbuild.org/ logo
c

clever-table-90691

06/05/2020, 2:02 PM
Hi there, I got a question about coverage html report. We are currently on pants v.1.28 in pure v2 mode. After executing pytest, the junit xml results is generated successfully. How do I generate html coverage report on top of that? Pants was able to generate both xml and html report previously on v1 mode.
❀️ 1
p

polite-garden-50641

06/05/2020, 2:21 PM
You will need to add the following options:
Copy code
--use-coverage --pytest-coverage-report=xml
See
./pants --v2 --no-v1 help test.pytest
for details about them.
Currently you can only choose one type of report, but I have an open issue to add support for multiple ones in the same run. https://github.com/pantsbuild/pants/issues/9968
c

clever-table-90691

06/05/2020, 2:25 PM
thanks @polite-garden-50641 ! I'll give that a try
p

polite-garden-50641

06/05/2020, 2:25 PM
Please note that this is still somewhat experimental.. (hence it is not in the docs yet), it should declared stable in the next few weeks.
πŸ‘Œ 1
@hundreds-father-404 I think this is worth documenting, we can put some kind of notice on the docs about this.
πŸ‘ 2
c

clever-table-90691

06/05/2020, 2:59 PM
I added the flag
--test-pytest-coverage-reports=html
but pants is not generating the html report.. would I be able to choose between xml or html report in v.1.28?
h

hundreds-father-404

06/05/2020, 3:30 PM
That’s the wrong option. Run
help-advanced pytest
. Sorry for the confusion
c

clever-table-90691

06/05/2020, 4:18 PM
hey @hundreds-father-404 The options listed are only for XML result files.. there's no option for generating html report πŸ˜•
h

hundreds-father-404

06/05/2020, 4:54 PM
Aww @clever-table-90691 sorry I was afk and gave you the wrong advice! My apologies. Please set the option
report = "html"
in the
[pytest-coverage]
option scope. Aka,
--pytest-coverage-report=html
.
Sorry about the confusion - we will document this very soon
c

clever-table-90691

06/05/2020, 4:58 PM
no worries, let me give that a try πŸ™‚ thanks
Both worked!! Using either [pytest-coverage] with report option OR the flag --pytest-coverage-report=html worked! And it executed way faster than v1! I'm also able to generate both xml and html report by keeping the junit_xml_dir option in [pytest] Thanks a lot for both of your help πŸ™‚
πŸ‘ 1
❀️ 2
h

hundreds-father-404

06/05/2020, 5:32 PM
Yay! Glad to hear! And yes, the flag and pants.toml values are the same
4 Views