summaryrefslogtreecommitdiffstats
path: root/junit4/src/test/java/org/junit/tests/running/classes/UseSuiteAsASuperclassTest.java
blob: 29171814235842c47b363cc4849521e10ad6c545 (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
package org.junit.tests.running.classes;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.model.InitializationError;

public class UseSuiteAsASuperclassTest {

	public static class TestA {
		@Test
		public void pass() {
		}
	}

	public static class TestB {
		@Test
		public void dontPass() {
			fail();
		}
	}

	public static class MySuite extends Suite {
		public MySuite(Class<?> klass) throws InitializationError {
			super(klass, new Class[] { TestA.class, TestB.class });
		}
	}

	@RunWith(MySuite.class)
	public static class AllWithMySuite {
	}

	@Test
	public void ensureTestsAreRun() {
		JUnitCore core= new JUnitCore();
		Result result= core.run(AllWithMySuite.class);
		assertEquals(2, result.getRunCount());
		assertEquals(1, result.getFailureCount());
	}
}