SDA Commons Server Testing¶
The module sda-commons-server-testing
is the base module to add unit and integrations test for applications in the
SDA SE infrastructure.
It provides JUnit test extensions that are helpful in integration tests.
Add the module with test scope:
1 |
|
1 2 3 4 5 6 7 8 |
|
Provided Assertions¶
GoldenFileAssertions¶
Special assertions for Path
objects to check if a file matches the expected contents and updates
them if needed. These assertions are helpful to check if certain files are stored in the repository
(like OpenAPI or AsyncApi).
Use this assertion if you want to conveniently store the latest copy of a file in your repository, and let the CI fail if an update has not been committed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
There is also a assertThat(...).hasYamlContentAndUpdateGolden(...)
variant that interprets the content as
YAML or JSON and ignores the order of keys. If possible, prefer the other variant since the written
content should always be reproducible. Note that the AsyncAPI and
OpenAPI generations export reproducible content.
SystemPropertyClassExtension¶
The SystemPropertyClassExtension
allows for overriding or unsetting system properties for (integration) tests and resets them to their original value when the tests have finished.
To use the extension, register it to your test class via the JUnit5 @RegisterExtension
:
1 2 3 4 5 6 |
|
Provided JUnit 5 Extensions¶
SystemPropertyClassExtension¶
This module provides the SystemPropertyClassExtension
,
a JUnit5 test extension to set and unset system properties before running an integration test.
To use the extension register it to your test class via the JUnit5 @RegisterExtension
:
1 2 3 4 5 6 |
|
Set and overwritten values will be reset to their original value once the test has finished.
JUnit Pioneer¶
For JUnit 5 we will not supply a replacement for the EnvironmentRule
and DropwizardRuleHelper
.
- The
EnvironmentRule
can be replaced with JUnit Pioneer capabilities. Anyway please read the warning above for overriding environment variables. - Use
DropwizardAppExtension
directly as a replacement for theDropwizardRuleHelper
.