⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 junit38classrunnertest.java

📁 junit
💻 JAVA
字号:
package org.junit.tests.junit3compatibility;import static org.junit.Assert.assertEquals;import junit.extensions.TestDecorator;import junit.framework.JUnit4TestAdapter;import junit.framework.TestCase;import junit.framework.TestSuite;import org.junit.Assert;import org.junit.Test;import org.junit.internal.runners.JUnit38ClassRunner;import org.junit.runner.Description;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;import org.junit.runner.notification.RunListener;public class JUnit38ClassRunnerTest {	public static class MyTest extends TestCase {		public void testA() {					}	}		@Test public void plansDecoratorCorrectly() {		JUnit38ClassRunner runner= new JUnit38ClassRunner(new TestDecorator(new TestSuite(MyTest.class)));		assertEquals(1, runner.testCount());	}		public static class AnnotatedTest {		@Test public void foo() {			Assert.fail();		}	}		@Test public void canUnadaptAnAdapter() {		JUnit38ClassRunner runner= new JUnit38ClassRunner(new JUnit4TestAdapter(AnnotatedTest.class));		Result result= new JUnitCore().run(runner);		Failure failure= result.getFailures().get(0);		assertEquals(Description.createTestDescription(AnnotatedTest.class, "foo"), failure.getDescription());	}		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());	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -