summaryrefslogtreecommitdiffstats
path: root/junit4/src/test/java/org/junit/tests/running/methods/InheritedTestTest.java
blob: 15f55a6f010a4c4b012828648ba970dd097fab5c (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
package org.junit.tests.running.methods;

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.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;

public class InheritedTestTest {
	public abstract static class Super {
		@Test public void nothing() {}
	}
	public static class Sub extends Super {}
	
	@Test public void subclassWithOnlyInheritedTestsRuns() {
		Result result= JUnitCore.runClasses(Sub.class);
		assertTrue(result.wasSuccessful());
	}
	
	public static class SubWithBefore extends Super {
		@Before public void gack() {
			fail();
		}
	}
	
	@Test public void subclassWithInheritedTestAndOwnBeforeRunsBefore() {
		assertFalse(JUnitCore.runClasses(SubWithBefore.class).wasSuccessful());
	}
}