aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2020-03-03 22:53:47 +0200
committerGitHub <noreply@github.com>2020-03-03 21:53:47 +0100
commitc73490ef1aa3d56d5530f695748236a1fe146498 (patch)
treea00582acb5f217bff6d1fc24df008b3300c1ced9 /org.jacoco.core.test
parent3b95f61698e0e2c2db71a313f0f959a8b6f0377e (diff)
downloadjacoco-c73490ef1aa3d56d5530f695748236a1fe146498.tar.gz
Upgrade JUnit to 4.13 (#1026)
Diffstat (limited to 'org.jacoco.core.test')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/Pack200StreamsTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java32
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/runtime/InjectedClassRuntimeTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementExecutorTest.java37
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementParserTest.java39
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java15
9 files changed, 73 insertions, 60 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java
index 6acb8f5e..9fc20df3 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java
@@ -39,10 +39,10 @@ import org.jacoco.core.data.ExecutionDataStore;
import org.jacoco.core.internal.Pack200Streams;
import org.jacoco.core.internal.data.CRC64;
import org.jacoco.core.test.TargetLoader;
+import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.internal.AssumptionViolatedException;
import org.junit.rules.TemporaryFolder;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
diff --git a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java
index 9a4a1c10..b2d27a97 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/instr/InstrumenterTest.java
@@ -39,9 +39,9 @@ import org.jacoco.core.internal.data.CRC64;
import org.jacoco.core.internal.instr.InstrSupport;
import org.jacoco.core.runtime.IExecutionDataAccessorGenerator;
import org.jacoco.core.test.TargetLoader;
+import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.Test;
-import org.junit.internal.AssumptionViolatedException;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java
index 75db677e..68fb4807 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/ContentTypeDetectorTest.java
@@ -24,8 +24,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.jacoco.core.test.TargetLoader;
+import org.junit.AssumptionViolatedException;
import org.junit.Test;
-import org.junit.internal.AssumptionViolatedException;
/**
* Unit tests for {@link ContentTypeDetector}.
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/Pack200StreamsTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/Pack200StreamsTest.java
index c8290fac..d489f9d4 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/Pack200StreamsTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/Pack200StreamsTest.java
@@ -31,8 +31,8 @@ import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.jacoco.core.test.TargetLoader;
+import org.junit.AssumptionViolatedException;
import org.junit.Test;
-import org.junit.internal.AssumptionViolatedException;
/**
* Unit tests for {@link Pack200Streams}.
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
index c0bd3732..924e61be 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
@@ -16,11 +16,10 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
@@ -37,9 +36,6 @@ public class InstrSupportTest {
private Printer printer;
private TraceMethodVisitor trace;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Before
public void setup() {
printer = new Textifier();
@@ -142,20 +138,26 @@ public class InstrSupportTest {
@Test
public void assertNotIntrumented_should_throw_exception_when_jacoco_data_field_is_present() {
- exception.expect(IllegalStateException.class);
- exception.expectMessage(
- "Cannot process instrumented class Foo. Please supply original non-instrumented classes.");
-
- InstrSupport.assertNotInstrumented("$jacocoData", "Foo");
+ try {
+ InstrSupport.assertNotInstrumented("$jacocoData", "Foo");
+ fail("exception expected");
+ } catch (IllegalStateException e) {
+ assertEquals(
+ "Cannot process instrumented class Foo. Please supply original non-instrumented classes.",
+ e.getMessage());
+ }
}
@Test
public void assertNotIntrumented_should_throw_exception_when_jacoco_init_method_is_present() {
- exception.expect(IllegalStateException.class);
- exception.expectMessage(
- "Cannot process instrumented class Foo. Please supply original non-instrumented classes.");
-
- InstrSupport.assertNotInstrumented("$jacocoInit", "Foo");
+ try {
+ InstrSupport.assertNotInstrumented("$jacocoInit", "Foo");
+ fail("exception expected");
+ } catch (IllegalStateException e) {
+ assertEquals(
+ "Cannot process instrumented class Foo. Please supply original non-instrumented classes.",
+ e.getMessage());
+ }
}
@Test
diff --git a/org.jacoco.core.test/src/org/jacoco/core/runtime/InjectedClassRuntimeTest.java b/org.jacoco.core.test/src/org/jacoco/core/runtime/InjectedClassRuntimeTest.java
index 64b8462d..c4edff15 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/runtime/InjectedClassRuntimeTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/runtime/InjectedClassRuntimeTest.java
@@ -17,10 +17,10 @@ import static org.junit.Assert.fail;
import java.lang.reflect.InvocationTargetException;
+import org.junit.AssumptionViolatedException;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.internal.AssumptionViolatedException;
import org.junit.rules.TestName;
/**
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementExecutorTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementExecutorTest.java
index 3aa3540f..2fb0a2b0 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementExecutorTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementExecutorTest.java
@@ -13,6 +13,7 @@
package org.jacoco.core.test.validation;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Arrays;
@@ -21,18 +22,13 @@ import java.util.List;
import java.util.Map;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link StatementExecutor}.
*/
public class StatementExecutorTest {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
private Map<String, List<?>> invocations;
@Before
@@ -63,29 +59,36 @@ public class StatementExecutorTest {
@Test
public void should_preserve_AssertionError() {
- exception.expect(AssertionError.class);
- exception.expectMessage("Original AssertionError.");
StatementExecutor executor = new StatementExecutor(this);
-
- executor.visitInvocation("ctx", "target3");
+ try {
+ executor.visitInvocation("ctx", "target3");
+ fail("exception expected");
+ } catch (AssertionError e) {
+ assertEquals("Original AssertionError.", e.getMessage());
+ }
}
@Test
public void should_wrap_other_exceptions() {
- exception.expect(RuntimeException.class);
- exception.expectMessage("Invocation error (ctx)");
StatementExecutor executor = new StatementExecutor(this);
-
- executor.visitInvocation("ctx", "target4");
+ try {
+ executor.visitInvocation("ctx", "target4");
+ fail("exception expected");
+ } catch (RuntimeException e) {
+ assertEquals("Invocation error (ctx)", e.getMessage());
+ assertEquals("Original IOException.", e.getCause().getMessage());
+ }
}
@Test
public void should_throw_RuntimeException_when_method_cannot_be_invoked() {
- exception.expect(RuntimeException.class);
- exception.expectMessage("Invocation error (ctx)");
StatementExecutor executor = new StatementExecutor(this);
-
- executor.visitInvocation("ctx", "doesNotExist");
+ try {
+ executor.visitInvocation("ctx", "doesNotExist");
+ fail("exception expected");
+ } catch (RuntimeException e) {
+ assertEquals("Invocation error (ctx)", e.getMessage());
+ }
}
public void target1(String a, String b, String c) {
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementParserTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementParserTest.java
index 7f418ec6..f7c9dd3f 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementParserTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/StatementParserTest.java
@@ -13,6 +13,7 @@
package org.jacoco.core.test.validation;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -22,9 +23,7 @@ import java.util.List;
import org.jacoco.core.test.validation.StatementParser.IStatementVisitor;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link StatementParser}
@@ -36,9 +35,6 @@ public class StatementParserTest {
private List<String> actualInvocations;
private List<String> expectedInvocations;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Before
public void setup() {
actualInvocations = new ArrayList<String>();
@@ -106,28 +102,43 @@ public class StatementParserTest {
@Test
public void should_fail_when_parenthesis_is_missing() throws IOException {
- exception.expect(IOException.class);
- StatementParser.parse("bad(", visitor, "Foo.java");
+ try {
+ StatementParser.parse("bad(", visitor, "Foo.java");
+ fail("exception expected");
+ } catch (IOException e) {
+ // expected
+ }
}
@Test
public void should_fail_when_argument1_is_missing() throws IOException {
- exception.expect(IOException.class);
- StatementParser.parse("bad(,2)", visitor, "Foo.java");
+ try {
+ StatementParser.parse("bad(,2)", visitor, "Foo.java");
+ fail("exception expected");
+ } catch (IOException e) {
+ // expected
+ }
}
@Test
public void should_fail_when_argument2_is_missing() throws IOException {
- exception.expect(IOException.class);
- StatementParser.parse("bad(1,)", visitor, "Foo.java");
+ try {
+ StatementParser.parse("bad(1,)", visitor, "Foo.java");
+ fail("exception expected");
+ } catch (IOException e) {
+ // expected
+ }
}
@Test
public void should_give_context_info_when_parsing_fails()
throws IOException {
- exception.expect(IOException.class);
- exception.expectMessage("Invalid syntax (Foo.java:32)");
- StatementParser.parse("bad", visitor, "Foo.java:32");
+ try {
+ StatementParser.parse("bad", visitor, "Foo.java:32");
+ fail("exception expected");
+ } catch (IOException e) {
+ assertEquals("Invalid syntax (Foo.java:32)", e.getMessage());
+ }
}
private void expectInvocation(String ctx, String name, Object... args) {
diff --git a/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java b/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java
index c23f0a67..54f64969 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/tools/ExecDumpClientTest.java
@@ -33,9 +33,7 @@ import org.jacoco.core.runtime.RemoteControlReader;
import org.jacoco.core.runtime.RemoteControlWriter;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link ExecDumpClient}.
@@ -50,9 +48,6 @@ public class ExecDumpClientTest {
private ServerSocket server;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
@Before
public void setup() {
callbacks = new ArrayList<String>();
@@ -136,11 +131,13 @@ public class ExecDumpClientTest {
@Test
public void should_throw_IOException_when_server_closes_connection_without_response()
throws IOException {
- exception.expect(IOException.class);
- exception.expectMessage("Socket closed unexpectedly.");
-
int port = createNopServer();
- client.dump((String) null, port);
+ try {
+ client.dump((String) null, port);
+ fail("exception expected");
+ } catch (IOException e) {
+ assertEquals("Socket closed unexpectedly.", e.getMessage());
+ }
}
private int getFreePort() throws IOException {