public final class StartupErrorRule
extends java.lang.Object
implements org.junit.rules.TestRule
Extra dependency 'com.github.stefanbirkner:system-rules:1.16.0' is required.
In spock tests, 'then' section must contain rule.indicatorExceptionType (or thrown(CheckExitCalled))
as rule can't intercept this exception.
'then' section can be used for assertions after system exit and so no need to register custom callback in the rule.
| Modifier and Type | Class and Description |
|---|---|
static interface |
StartupErrorRule.AfterExitAssertion
Interface implementation may be registered to check assertions after system exit.
|
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
StartupErrorRule |
checkAfterExit(StartupErrorRule.AfterExitAssertion check)
In junit it is impossible to use assertion lines after
System.exit() call. |
static StartupErrorRule |
create()
Use with spock tests or when no assertions required after system exit call.
|
static StartupErrorRule |
create(StartupErrorRule.AfterExitAssertion check)
This is useful for junit tests, because there is no other way to check anything after exit call.
|
java.lang.String |
getError()
Dropwizard exception will be presented here.
|
java.lang.Class<? extends java.lang.Exception> |
getIndicatorExceptionType()
Useful only for spock tests because in junit rule can intercept this exception implicitly.
|
java.lang.String |
getOutput()
NOTE: useful only for spock tests.
|
public static StartupErrorRule create()
public static StartupErrorRule create(StartupErrorRule.AfterExitAssertion check)
check - assertion callback to execute after exit callpublic StartupErrorRule checkAfterExit(StartupErrorRule.AfterExitAssertion check)
System.exit() call. This method will register
a custom check callback to validate state after system exit call.
May be called multiple times.
NOTE: in spock there is no need for it, because 'then' section will be called.
check - assertion commandExpectedSystemExit.checkAssertionAfterwards(org.junit.contrib.java.lang.system.Assertion)public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRulepublic java.lang.String getOutput()
public java.lang.String getError()
NOTE: useful only for spock tests.
public java.lang.Class<? extends java.lang.Exception> getIndicatorExceptionType()