prejunit4testcaserunnertest.java
来自「JUnit, java testing tool」· Java 代码 · 共 44 行
JAVA
44 行
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)); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?