blob: 7cdfbb7c474824a82b1121badb2fceb04d1b0776 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package org.junit.tests.deprecated;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
/*
* @deprecated This is a simple smoke test to make sure the old JUnit4ClassRunner basically works.
* Delete this test when JUnit4ClassRunner goes to the Great Heap In The Sky.
*/
@Deprecated
public class JUnit4ClassRunnerTest {
@SuppressWarnings("deprecation")
@RunWith(JUnit4ClassRunner.class)
public static class Example {
@Test public void success() {}
@Test public void failure() {
fail();
}
}
@Test
public void runWithOldJUnit4ClassRunner() {
Result result= JUnitCore.runClasses(Example.class);
assertThat(result.getRunCount(), is(2));
assertThat(result.getFailureCount(), is(1));
}
@SuppressWarnings("deprecation")
@RunWith(JUnit4ClassRunner.class)
public static class UnconstructableExample {
public UnconstructableExample() {
throw new UnsupportedOperationException();
}
@Test public void success() {}
@Test public void failure() {
fail();
}
}
@Test
public void runWithOldJUnit4ClassRunnerAndBadConstructor() {
Result result= JUnitCore.runClasses(UnconstructableExample.class);
assertThat(result.getRunCount(), is(2));
assertThat(result.getFailureCount(), is(2));
}
}
|