我知道一种方法是:
@Test
public void foo(){
try{
//execute code that you expect not to throw Exceptions.
}
catch(Exception e){
fail("Should not have thrown any exception");
}
}
Run Code Online (Sandbox Code Playgroud)
有没有更清洁的方法来做到这一点.(可能使用Junit的@Rule?)