Test should fail if exitProcess/System.exit called, unless explicitly expected
See original GitHub issueI have a few functions that I currently cannot fully test because they call exitProcess(returnCode)
. I’d like kotlintest to report a failure if exitProcess/System.exit
is called (rather than just terminating the test), unless I’ve explicitly told it I’m expecting it to be called, with an optional way to check the return code.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Test should fail if exitProcess/System.exit called, unless ...
I'd like kotlintest to report a failure if exitProcess/System.exit is called (rather than just terminating the test), unless I've explicitly ...
Read more >Java: How to test methods that call System.exit()?
Try modifying the TestCase to run with a security manager that prevents calling System. exit, then catch the SecurityException.
Read more >Testing System.exit() with JUnit5 - Todd Ginsberg
Writing a unit test that actually exits the JVM while it is under test is definitely not ideal. Whenever the JVM does something...
Read more >Exception Handling — Python 3.11.1 documentation
Unless the error is a SystemExit , in that case no traceback is printed and the Python process will exit with the error...
Read more >Best practices for writing unit tests - .NET - Microsoft Learn
When you have a suite of well-named unit tests, each test should be able to clearly explain the expected output for a given...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been added to master in the form of an extension and will be included in 3.1.0.
https://github.com/kotlintest/kotlintest/blob/master/kotlintest-extensions/kotlintest-extensions-system/src/test/kotlin/io/kotlintest/extensions/system/SystemExitTest.kt
SpecSystemExitListener
is the wrong name, should beSystemExitSpecListener
. I’ll have to deprecate it and add another at some point.