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

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.InitializationError;

public class BlockJUnit4ClassRunnerTest {
	public static class OuterClass {
		public class Enclosed {
			@Test
			public void test() {
			}
		}
	}

	@Test
	public void detectNonStaticEnclosedClass() throws Exception {
		try {
			new BlockJUnit4ClassRunner(OuterClass.Enclosed.class);
		} catch (InitializationError e) {
			List<Throwable> causes= e.getCauses();
			assertEquals("Wrong number of causes.", 1, causes.size());
			assertEquals(
					"Wrong exception.",
					"The inner class org.junit.tests.running.classes.BlockJUnit4ClassRunnerTest$OuterClass$Enclosed is not static.",
					causes.get(0).getMessage());
		}
	}
}