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

📄 exceptiontestcasetest.java

📁 Java测试工具Junit3.8.1官方发布源码
💻 JAVA
字号:
package junit.tests.extensions;import junit.framework.*;import junit.extensions.*;public class ExceptionTestCaseTest extends junit.framework.TestCase {	static public class ThrowExceptionTestCase extends ExceptionTestCase {		public ThrowExceptionTestCase(String name, Class exception) {			super(name, exception);		}		public void test() {			throw new IndexOutOfBoundsException();		}	}	static public class ThrowRuntimeExceptionTestCase extends ExceptionTestCase {		public ThrowRuntimeExceptionTestCase(String name, Class exception) {			super(name, exception);		}		public void test() {			throw new RuntimeException();		}	}	static public class ThrowNoExceptionTestCase extends ExceptionTestCase {		public ThrowNoExceptionTestCase(String name, Class exception) {			super(name, exception);		}		public void test() {		}	}	public void testExceptionSubclass() {		ExceptionTestCase test= new ThrowExceptionTestCase("test", IndexOutOfBoundsException.class);		TestResult result= test.run();		assertEquals(1, result.runCount());		assertTrue(result.wasSuccessful());	}	public void testExceptionTest() {		ExceptionTestCase test= new ThrowExceptionTestCase("test", IndexOutOfBoundsException.class);		TestResult result= test.run();		assertEquals(1, result.runCount());		assertTrue(result.wasSuccessful());	}	public void testFailure() {		ExceptionTestCase test= new ThrowRuntimeExceptionTestCase("test", IndexOutOfBoundsException.class);		TestResult result= test.run();		assertEquals(1, result.runCount());		assertEquals(1, result.errorCount());	}	public void testNoException() {		ExceptionTestCase test= new ThrowNoExceptionTestCase("test", Exception.class);		TestResult result= test.run();		assertEquals(1, result.runCount());		assertEquals(1, result.failureCount());	}	public void testWrongException() {		ExceptionTestCase test= new ThrowRuntimeExceptionTestCase("test", IndexOutOfBoundsException.class);		TestResult result= test.run();		assertEquals(1, result.runCount());		assertEquals(1, result.errorCount());	}}

⌨️ 快捷键说明

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