Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例外マッパーの使用中にJunit4を使用して、スローされた例外をテストするにはどうすればよいですか?
実行から予想される、スローされた例外をテストします。使ってください :
@Test(expected=<ExpectedException>.class) public void testThrownException() { // Your test code that throws the expected exception }
コードが予想される例外をスローし、アサーションの失敗やコードによってスローされたその他の例外で失敗する場合、テストは成功します。