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

Add integration testing support by never calling System.exit #367

Closed
bobtiernay-okta opened this issue Apr 22, 2018 · 3 comments
Closed

Comments

@bobtiernay-okta
Copy link
Contributor

At the very least, there should be some documentation describing how one is expected to test applications built with picocli. However, much can be improved by never calling System.exit, but instead deferring this to the actual application. This way, one can easily test applications by asserting on exit codes. This is currently possible in JCommander for example. Something similar to the Spring Boot starter's ExitStatus is what I'm thinking.

@remkop
Copy link
Owner

remkop commented Apr 23, 2018

I'm not sure that I understand the problem: picocli only calls System.exit if requested by the application, as documented here: http://picocli.info/#_exit_code . If the andExit(int) method is not called, picocli will not call System.exit.

Good point about documenting how to test picocli-based applications. This topic came up before (see #218) and it's on my todo list to write an article about testing.

To give you a quick tip: I've started to use Stephan Birkner's SystemErrAndOutRule and ExpectedSystemExit rule. This works very well for JUnit 4. If you using JUnit 5, and you need this urgently, you can offer Stefan to help with his work in progress on a JUnit 5 extension.

@remkop
Copy link
Owner

remkop commented Apr 23, 2018

From this ticket's title I am guessing there may have been a misunderstanding, am I correct?

@bobtiernay-okta
Copy link
Contributor Author

Correct, sorry, and thank's for the links!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants