Skip to content
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

Json CLI Argument #194

Closed
rob-mur opened this issue Dec 29, 2021 · 9 comments · Fixed by #220
Closed

Json CLI Argument #194

rob-mur opened this issue Dec 29, 2021 · 9 comments · Fixed by #220
Assignees
Labels
enhancement Improvement of existing features or bugfix
Milestone

Comments

@rob-mur
Copy link

rob-mur commented Dec 29, 2021

Hi

I've been having a go at using CLion for rust with Cucumber, and have ran into an issue.

When tests are ran they append a format=json argument to the inner test harness. This is different to the JSON output required by smartbear for their cucumber for jira integration, an example of what standard lib tests output is below:

{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.0005077 }

This looks relatively simple, and I'm not sure yet which bits are actually required by CLion, but please let me know if anyone has any information. Otherwise over the next little while I'll see if I can get a working fork.

@tyranron
Copy link
Member

@rob-mur I cannot really grasp what you're after here. Could you provide a little bit more of context?

Regarding JSON exapmples, aren't they about Cucumber Messages protocol?

@rob-mur
Copy link
Author

rob-mur commented Dec 29, 2021

So I don't think this is related to cucumber but rust more generally. One of the cli options of cargo test is -- --format which clion is using to get JSON output of the tests (just pass fail pieces I think).

The issue is that this cli argument is passed in to the test harness (in this case cucumber) which currently throws an error (at least for me on the latest release).

I'm away from my pc but from memory the error is that "json formatter is only available on the nightly compiler", however changing to nightly doesn't seem to resolve it.

To recreate for yourself, just try running some set of tests with cargo test -- --format=json and see what happens.

@rob-mur
Copy link
Author

rob-mur commented Dec 29, 2021

The exact error I'm getting is

error: The "json" format is only accepted on the nightly compiler

I'll see if I can narrow down where exactly this is happening.

@ilslv
Copy link
Member

ilslv commented Dec 30, 2021

@rob-mur the problem with CLion is, that it's always expects default test harness which has --format=json option. Our crate requires you to specify harness = false to be able to hijack cargo test command. This article may also help.
For example you can specify CLion cargo configuration to run test --test wait -- --tags='@any', but resulting command will be cargo test --color=always --test wait --no-fail-fast -- --format=json --tags='@any' -Z unstable-options --show-output. The solution would be to use Cucumber::with_cli but instead of before_time, use format to skip this argument.

@rob-mur
Copy link
Author

rob-mur commented Dec 30, 2021

Thanks for the response. I'll have a go later and see what the result is with that argument skipped as you suggest.

It may be however that this output is required to integrate properly with the IDE and then we could look in to taking this argument and producing an equivalent output?

@ilslv
Copy link
Member

ilslv commented Dec 30, 2021

@rob-mur

It may be however that this output is required to integrate properly with the IDE and then we could look in to taking this argument and producing an equivalent output?

I'll look into that and maybe implement custom Writer for that purpose if it's possible.

@rob-mur
Copy link
Author

rob-mur commented Dec 30, 2021

@rob-mur

It may be however that this output is required to integrate properly with the IDE and then we could look in to taking this argument and producing an equivalent output?

I'll look into that and maybe implement custom Writer for that purpose if it's possible.

I've had a go, and using a custom cli struct for format, Z and show-output, you can get CLion to run the tests.

This is already a great step forward as it allows you to utilise the CLion debugger in tests so many thanks for that!

My gut feeling was right though in that as far as the IDE is concerned there are no test results so it doesn't quite integrate as expected.

Feel free to have a go if you like but it's not particularly high priority!

@tyranron tyranron added enhancement Improvement of existing features or bugfix postponed Postponed due to lack of implementation reasons labels Dec 31, 2021
@tyranron
Copy link
Member

@ilslv given #203 and #218 I think this now diserves to be implemented on our side behind a "clion" feature gate.

@tyranron tyranron removed the postponed Postponed due to lack of implementation reasons label Jun 16, 2022
@tyranron tyranron added this to the 0.14.0 milestone Jun 16, 2022
tyranron added a commit that referenced this issue Jul 20, 2022
…e with IntelliJ Rust pugin (#220, #194, #203, #218)

- add `libtest` Cargo feature
- impl `writer::Libtest`
- describe IntelliJ Rust integration in Book

Additionally:
- rework `writer::Failure`/`writer::discard::Failure` as `writer::Stats`/`writer::discard::Stats`
- add `writer::Or` to alternate between 2 `Writer`s basing on predicate
- add `FeatureExt::count_steps()` method

Co-authored-by: Kai Ren <tyranron@gmail.com>
@tyranron
Copy link
Member

tyranron commented Sep 8, 2022

@rob-mur released in 0.14.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants