1 package junit.tests.runner;
2
3 import java.io.ByteArrayOutputStream;
4 import java.io.PrintStream;
5
6 import junit.framework.TestCase;
7 import junit.textui.ResultPrinter;
8 import junit.textui.TestRunner;
9
10
11
12
13 public class TextRunnerSingleMethodTest extends TestCase {
14
15 static boolean fgWasInvoked;
16
17 public static class InvocationTest extends TestCase {
18
19 public void testWasInvoked() {
20 TextRunnerSingleMethodTest.fgWasInvoked = true;
21 }
22
23 public void testNotInvoked() {
24 fail("Shouldn't get here.");
25 }
26 }
27
28 public void testSingle() throws Exception {
29 TestRunner t = new TestRunner();
30 t.setPrinter(new ResultPrinter(new PrintStream(new ByteArrayOutputStream())));
31 String[] args = {
32 "-m", "junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest.testWasInvoked"
33 };
34 fgWasInvoked = false;
35 t.start(args);
36 assertTrue(fgWasInvoked);
37 }
38
39 }