Based on the excellent work by Stefan Birkner in System Rules and System Lambda this is a remix of the core techniques, to allow them to be used more flexibly.
No longer limited to just being a JUnit4 rule (SystemRules) and available as a JUnit 5 plugin, this version is intended to increase usability and configurability, in a way that diverges from the original trajectory of System Lambda.
This version comes with the agreement of the original author. The original author bears no responsibility for this version.
The main aims of this version:
- Enable environment variables to be set before child test suites execute
- allow environment details to be set in beforeAll or beforeEach hooks
- as can be necessary for Spring tests
- Support JUnit4 and JUnit5 plugins
- reduce test boilerplate
- Provide more configuration and fluent setters
- Modularise the code
- Standardise testing around Mockito and AssertJ
- Standardise around the Java Library as much as possible
In order to support migration from System Lambda, and to enable reuse of the original unit tests, the SystemStubs
facade supports the execute around idiom.
To use the SystemStubs
facade:
import static uk.org.webcompere.systemstubs.SystemStubs.*;
Then methods like assertNothingWrittenToSystemOut
or restoreSystemProperties
will work as they did in System Lambda.