summaryrefslogtreecommitdiffstats
path: root/junit4/src/test/java/junit/tests/runner/TextRunnerSingleMethodTest.java
blob: 1034fdd4ee6c9dad1f23b0d7f60d8551ab785ae8 (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
package junit.tests.runner;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import junit.framework.TestCase;
import junit.textui.ResultPrinter;
import junit.textui.TestRunner;

/**
 *  Test invoking a single test method of a TestCase.
 */
public class TextRunnerSingleMethodTest extends TestCase {
	
	static boolean fgWasInvoked;
	
	public static class InvocationTest extends TestCase {

		public void testWasInvoked() {
			TextRunnerSingleMethodTest.fgWasInvoked= true;
		}

		public void testNotInvoked() {
			fail("Shouldn't get here.");
		}
	}
	
	public void testSingle() throws Exception {
		TestRunner t= new TestRunner();
		t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream())));
		String[] args= {
				"-m", "junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked"
		};
		fgWasInvoked= false;
		t.start(args);
		assertTrue(fgWasInvoked);
	}

}