@Error
ETLUnit 3.9.6
Description
- Annotation on a test method.
- Causes an 'error' type of exception to be thrown from the test method.
- Will appear in the CLI as an
ERR_UNSPECIFIED
, unless the@Test
annotation on the same test method has an attributeexpected-error-id
, with 'ERROR_UNSPECIFIED
as its value. @Error
Throws an exception after the last executable line in the method executes.- If an error occurs during the method, causing it to stop and throw an error, that error will show in the log, but not on the command line.
ERR_UNSPECIFIED
will override whatever that error may be. - Useful for debugging.
Attributes
Attribute Name | Required? | Possible Values | Info |
---|---|---|---|
description | Yes |
|
|
Location in the test class file
Before a test method.
Examples
The following test will pass, because the error is "caught."
The @Test
annotation has an expected-error-id of 'ERR_UNSPECIFIED
.'
@Error gets caught by @Test
@Test(expected-error-id: 'ERR_UNSPECIFIED')
@Error(description: 'Demonstration of the @Error annotation.')
executeError()
{
log(
message: 'Annotated with Error',
log-file-name: 'test_me.log',
log-classifier: 'anyClassifier'
);
}
The following test will produce an error, because there is nothing to catch the error forced by the @Error
annotation.
@Error does not get caught
@Test
@Error(description: 'Demonstration of the @Error annotation.')
executeError()
{
log(
message: 'Annotated with Error',
log-file-name: 'test_me.log',
log-classifier: 'anyClassifier'
);
}