Handling System Properties, Environment Variables, STDOUT/STDERR in JUnit Tests with System Rules
When important data is written to STDIN/STDOUT and an application relies on specific system properties or environment variables, writing tests is getting more complicated. System Rules is a collection of JUnit rules that helps us writing Java tests for everything that deals with java.lang.System. In the following short examples I’d like to demonstrate how to deal with system properties, environment variables, STDOUT and STDERR and capturing both for testing e.g. for some golden master refactoring. ...