@Retention(value=RUNTIME) @Target(value={METHOD,ANNOTATION_TYPE}) @Documented @ExtendWith(value=ExpectedExceptionExtension.class) public @interface ExpectedException
Usage example:
// match an exception of type Exception containing the message "Boom!" @ExpectedException(type = RuntimeException.class, messageIs = "Boom!") // match an exception of type RuntimeException containing a message which starts with "Bye" @ExpectedException(type = RuntimeException.class, messageStartsWith = "Bye") // match an exception of type MyDomainException having a message which contains "ouch" @ExpectedException(type = MyDomainException.class, messageContains = "ouch")
| Modifier and Type | Required Element and Description |
|---|---|
Class<? extends Throwable> |
type |
| Modifier and Type | Optional Element and Description |
|---|---|
String |
messageContains |
String |
messageIs |
String |
messageStartsWith |
Copyright © 2017. All rights reserved.