JUnit Exception Testing: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:


* [[JUnit#Patterns|JUnit]]
* [[JUnit#Patterns|JUnit]]
=Idioms=
==Try/Catch==
<syntaxhighlight lang='java'>
try {
  ...
  fail("should have thrown exception");
}
catch(SomeException e) {
  assertEquals("some message", e.getMessage());
}
</syntaxhighlight>
==assertThrows()==

Revision as of 23:28, 26 August 2020

External

Internal

Idioms

Try/Catch

try {
  ...
  fail("should have thrown exception");
}
catch(SomeException e) {
  assertEquals("some message", e.getMessage());
}

assertThrows()