Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Before a test method.

Examples

The @Failure annotation does not generate a failure ID.

To fail gracefully using the @Failure annotation, the @Test annotation should use expected-error-id, not expected-failure-id as it would for natural failures or failures induced by the fail() operation.

This test will pass.

 

Section
Column
width25px

 

Column
width500px
Panel
bgColor#E0E6F8
titleColor#0B0B61
titleBGColor#CED8F6
title@Failure with a description. Error caught by @Test.

@Test(expected-error-id: 'FAIL_UNSPECIFIED')

@Failure(description: 'How did this FAILURE happen?')

executeFailure()

{

log(

message: 'Annotated with failure',

log-file-name: 'test_me.log',

log-classifier: 'anyClassifier'

);

}


Column

 

...

Section
Column
width25px

 

Column
width675px
Code Block
languagetext
themeRDark
title@Failure properly caught
userme > te #executeFailure
Processing [1] tests
class experiment.test_me   -------------------------------------------------------
1/1        .executeFailure
  Passed                                                                      P[1]
Tests run: 1, Successes: 1, Time elapsed: 0.178 sec
Column

 

Here is the @Failure annotation again, without a description.  It is functionally the same as the above example. 

...