aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.agent.rt.test
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2012-07-03 22:12:33 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2012-07-03 22:12:33 +0000
commit3ff8899bdee54f39ab728acf3bd97b5dfee7baad (patch)
treed4e5a09641747343e9edee03003f22e2b5cf001f /org.jacoco.agent.rt.test
parentcf41fc18ccb6773f10077dfb460d2c6b84f78858 (diff)
downloadjacoco-3ff8899bdee54f39ab728acf3bd97b5dfee7baad.tar.gz
In case of internal instrumentation errors also dump class name.
Diffstat (limited to 'org.jacoco.agent.rt.test')
-rw-r--r--org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/CoverageTransformerTest.java4
-rw-r--r--org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ExceptionRecorder.java15
2 files changed, 18 insertions, 1 deletions
diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/CoverageTransformerTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/CoverageTransformerTest.java
index c677671d..bfa1e7b6 100644
--- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/CoverageTransformerTest.java
+++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/CoverageTransformerTest.java
@@ -135,7 +135,9 @@ public class CoverageTransformerTest {
assertEquals("Error while instrumenting class org.jacoco.Sample.",
e.getMessage());
}
- recorder.assertException(NullPointerException.class, null);
+ recorder.assertException(IllegalClassFormatException.class,
+ "Error while instrumenting class org.jacoco.Sample.",
+ NullPointerException.class);
recorder.clear();
}
diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ExceptionRecorder.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ExceptionRecorder.java
index 181961b9..a997d417 100644
--- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ExceptionRecorder.java
+++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/ExceptionRecorder.java
@@ -42,6 +42,13 @@ public class ExceptionRecorder implements IExceptionLogger {
assertEquals(Collections.singletonList(message), getMessages());
}
+ public void assertException(final Class<? extends Throwable> type,
+ final String message, final Class<? extends Throwable> causetype) {
+ assertEquals(Collections.singletonList(type), getTypes());
+ assertEquals(Collections.singletonList(message), getMessages());
+ assertEquals(Collections.singletonList(causetype), getCauseTypes());
+ }
+
private List<Class<?>> getTypes() {
final List<Class<?>> types = new ArrayList<Class<?>>();
for (Exception e : exceptions) {
@@ -50,6 +57,14 @@ public class ExceptionRecorder implements IExceptionLogger {
return types;
}
+ private List<Class<?>> getCauseTypes() {
+ final List<Class<?>> types = new ArrayList<Class<?>>();
+ for (Exception e : exceptions) {
+ types.add(e.getCause().getClass());
+ }
+ return types;
+ }
+
private List<String> getMessages() {
final List<String> messages = new ArrayList<String>();
for (Exception e : exceptions) {