Created
February 24, 2015 06:16
-
-
Save marchof/d0f53b31f1bd3ca4dfa6 to your computer and use it in GitHub Desktop.
Validation test for jacoco/jacoco#286
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java | |
index a3bfa81..0845bd6 100644 | |
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java | |
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java | |
@@ -61,7 +61,17 @@ | |
assertLine("implicitExceptionTryCatch.catchBlock", | |
ICounter.FULLY_COVERED); | |
- // 5. Try/Catch Block With Exception Thrown Explicitly | |
+ // 5. Try/Catch Block With Exception Thrown Implicitly After Condition | |
+ // As the try/catch block is entered at one branch of the condition | |
+ // should be marked as executed | |
+ assertLine("implicitExceptionTryCatchAfterCondition.condition", | |
+ ICounter.PARTLY_COVERED, 1, 1); | |
+ assertLine("implicitExceptionTryCatchAfterCondition.exception", | |
+ ICounter.NOT_COVERED); | |
+ assertLine("implicitExceptionTryCatchAfterCondition.catchBlock", | |
+ ICounter.FULLY_COVERED); | |
+ | |
+ // 6. Try/Catch Block With Exception Thrown Explicitly | |
assertLine("explicitExceptionTryCatch.beforeBlock", | |
ICounter.FULLY_COVERED); | |
assertLine("explicitExceptionTryCatch.before", ICounter.FULLY_COVERED); | |
@@ -69,13 +79,13 @@ | |
assertLine("explicitExceptionTryCatch.catchBlock", | |
ICounter.FULLY_COVERED); | |
- // 6. Finally Block Without Exception Thrown | |
+ // 7. Finally Block Without Exception Thrown | |
// Finally block is yellow as the exception path is missing. | |
assertLine("noExceptionFinally.beforeBlock", ICounter.FULLY_COVERED); | |
assertLine("noExceptionFinally.tryBlock", ICounter.FULLY_COVERED); | |
assertLine("noExceptionFinally.finallyBlock", ICounter.PARTLY_COVERED); | |
- // 7. Finally Block With Implicit Exception | |
+ // 8. Finally Block With Implicit Exception | |
// Finally block is yellow as the non-exception path is missing. | |
assertLine("implicitExceptionFinally.beforeBlock", | |
ICounter.FULLY_COVERED); | |
@@ -85,7 +95,7 @@ | |
assertLine("implicitExceptionFinally.finallyBlock", | |
ICounter.PARTLY_COVERED); | |
- // 8. Finally Block With Exception Thrown Explicitly | |
+ // 9. Finally Block With Exception Thrown Explicitly | |
assertLine("explicitExceptionFinally.beforeBlock", | |
ICounter.FULLY_COVERED); | |
assertLine("explicitExceptionFinally.before", ICounter.FULLY_COVERED); | |
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target03.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target03.java | |
index 0ea2d69..41dfbe0 100644 | |
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target03.java | |
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target03.java | |
@@ -12,6 +12,7 @@ | |
package org.jacoco.core.test.validation.targets; | |
import static org.jacoco.core.test.validation.targets.Stubs.ex; | |
+import static org.jacoco.core.test.validation.targets.Stubs.f; | |
import static org.jacoco.core.test.validation.targets.Stubs.nop; | |
import org.jacoco.core.test.validation.targets.Stubs.StubException; | |
@@ -32,6 +33,7 @@ | |
} | |
noExceptionTryCatch(); | |
implicitExceptionTryCatch(); | |
+ implicitExceptionTryCatchAfterCondition(); | |
explicitExceptionTryCatch(); | |
noExceptionFinally(); | |
try { | |
@@ -75,6 +77,17 @@ | |
} | |
} | |
+ private void implicitExceptionTryCatchAfterCondition() { | |
+ if (f()) { // $line-implicitExceptionTryCatchAfterCondition.condition$ | |
+ return; | |
+ } | |
+ try { | |
+ ex(); // $line-implicitExceptionTryCatchAfterCondition.exception$ | |
+ } catch (StubException e) { | |
+ nop(); // $line-implicitExceptionTryCatchAfterCondition.catchBlock$ | |
+ } | |
+ } | |
+ | |
private void explicitExceptionTryCatch() { | |
nop(); // $line-explicitExceptionTryCatch.beforeBlock$ | |
try { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment