Package org.junit.tests

Source Code of org.junit.tests.PreJUnit4TestCaseRunnerTest$OneTest

package org.junit.tests;


import static org.junit.Assert.assertEquals;
import junit.framework.JUnit4TestAdapter;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;

public class PreJUnit4TestCaseRunnerTest {

  static int count;
 
  static public class OneTest extends TestCase {
    public void testOne() {
    }
  }
 
  @Test public void testListener() throws Exception {
    JUnitCore runner= new JUnitCore();
    RunListener listener= new RunListener() {
      @Override
      public void testStarted(Description description) {
        assertEquals(Description.createTestDescription(OneTest.class, "testOne"),
            description);
        count++;
      }
    };
   
    runner.addListener(listener);
    count= 0;
    Result result= runner.run(OneTest.class);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
  }
 
  public static junit.framework.Test suite() {
    return (new JUnit4TestAdapter(PreJUnit4TestCaseRunnerTest.class));
  }
}
TOP

Related Classes of org.junit.tests.PreJUnit4TestCaseRunnerTest$OneTest

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.