https://pantsbuild.org/ logo
m

modern-laptop-24399

04/23/2022, 3:42 AM
Has anyone had success using
pytest-bdd
and generating a cucumber.json report as a result of multiple test files being executed? I'm finding since a pants session is per-file, using the
--cucumberjson
option results in pants over-writing the cucumber JSON with the latest test-file execution.
h

happy-kitchen-89482

04/24/2022, 11:38 PM
Interesting, so
--cucumberjson
points to some global location? Yeah, that won't work. This is similar to coverage reports, which we handle specially, so we might have to do the same here.
Alternatively, is having a separate cucumber JSON file per test file useful? Or do they really need to be merged to one file to be of use?
I do see a tool for merging those reports, but it required npm to install, and so would be pretty heavyweight. And the merge logic seems pretty trivial (https://github.com/bitcoder/cucumber-json-merge/blob/master/lib/index.js) so might as well reimplement it in Python.
m

modern-laptop-24399

04/25/2022, 4:35 PM
so
--cucumberjson
points to some global location?
Yeah - I looked at their code. Pretty basic file-write at the end of an execution.
Alternatively, is having a separate cucumber JSON file per test file useful? Or do they really need to be merged to one file to be of use?
Similar to a coverage report, the cucumber report is more useful if it shows everything for sure. FWIW on the npm piece - The
cucumber-html-reporter
piece requires NPM, so perhaps not much by way of overhead.
Presently pants has a lot of "magic". What I wish for right now is a way to have pants treat sessions more holistically if required. I'm guessing that would be a pretty major change, but it would enable easier adoption b/c I could rely more on my existing
pytest
implementations instead of focusing on migrating to the pants model. #naiveStatements
h

happy-kitchen-89482

04/25/2022, 5:05 PM
Can you elaborate on what you mean by "holistically"? What would the example be in this case?
m

modern-laptop-24399

04/26/2022, 2:57 PM
Can you elaborate on what you mean by "holistically"? What would the example be in this case?
Sure. When executing
pytest
there is a single session that tests all modules in scope, whereas
./pants test ::
generates a session per python module. I suppose I'm really just speaking to this: https://github.com/pantsbuild/pants/issues/14941
Alternatively, is having a separate cucumber JSON file per test file useful? Or do they really need to be merged to one file to be of use?
I noticed today an option in the
cucumber-html-reporter
used with
pytest-bdd
that there's an option to use
jsonDir
to consolidate multiple JSON files... When I get back to this work, I may try this out and statically define a location since
./pants
generates
/tmp
dirs per session. I'll report back what I find.
h

happy-kitchen-89482

04/26/2022, 4:35 PM
Makes sense!
9 Views