Package junit.tests.runner

Source Code of junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest

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);
  }

}
TOP

Related Classes of junit.tests.runner.TextRunnerSingleMethodTest$InvocationTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.