Changes for "Guide to finally in Java" (BAEL-3526) (#8237)
* Adding files for finally keyword * Adding returnFromCatch example. * Adding empty braces instead of dangling ; * Return from try, removing the catch block. * moving to to core-java module * moving to core-java-lang-2
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.finallykeyword;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class PitfallsWhenUsingFinallyUnitTest {
|
||||
|
||||
PitfallsWhenUsingFinally instance = new PitfallsWhenUsingFinally();
|
||||
|
||||
@Test
|
||||
public void testIgnoresException() {
|
||||
String result = instance.disregardsUnCaughtException();
|
||||
assertEquals("from finally", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoresOtherReturns() {
|
||||
String result = instance.ignoringOtherReturns();
|
||||
assertEquals("from finally", result);
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testThrowsException() {
|
||||
instance.throwsException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user