blob: 3251705d24cb7cad099961e6deae9c075b4905ff (
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
|
package org.junit.tests.validation;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
public class ValidationTest {
public static class WrongBeforeClass {
@BeforeClass
protected int a() {
return 0;
}
}
@Test
public void initializationErrorIsOnCorrectClass() {
assertEquals(WrongBeforeClass.class.getName(),
Request.aClass(WrongBeforeClass.class).getRunner().getDescription().getDisplayName());
}
public static class NonStaticBeforeClass {
@BeforeClass public void before() {}
@Test public void hereBecauseEveryTestClassNeedsATest() {}
}
@Test
public void nonStaticBeforeClass() {
Result result= JUnitCore.runClasses(NonStaticBeforeClass.class);
assertEquals("Method before() should be static", result.getFailures().get(0).getMessage());
}
}
|