Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

assertj assert throws

// exception assertion, standard style ...
assertThatThrownBy(() -> { throw new Exception("boom!"); }).hasMessage("boom!");
// ... or BDD style
Throwable thrown = catchThrowable(() -> { throw new Exception("boom!"); });
assertThat(thrown).hasMessageContaining("boom");
Source by weblab.tudelft.nl #
 
PREVIOUS NEXT
Tagged: #assertj #assert #throws
ADD COMMENT
Topic
Name
3+7 =