Has anyone had success using `pytest-bdd` and gene...
# general
m
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
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
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
Can you elaborate on what you mean by "holistically"? What would the example be in this case?
m
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
Makes sense!