📄 exampletest.java
字号:
package org.hanselexample;import junit.framework.Test;import junit.framework.TestCase;import org.hansel.CoverageDecorator;/** * Coverage Test for the Example class. * This test covers all lines (including private/anonymous classes) * of the Example class. * * @author Niklas Mehner */public class ExampleTest extends TestCase { /** * Creates a new Test. * @param name Name of the test. */ public ExampleTest(String name) { super(name); } /** * Static method to create the TestSuit. * This wrapps the test in a CoverageDecorator. * @return TestSuit for this class. */ public static Test suite() { CoverageDecorator cd = new CoverageDecorator(ExampleJUnit4Test.class, new Class[] { Example.class }); cd.setDisplayStatistics(true); return cd; } /** * Test the Example.abs() method. */ public void testAbs() { Example example = new Example(); assertEquals("abs(1) should be 1.", 1, example.abs(1)); assertEquals("abs(-1) should be 1.", 1, example.abs(-1)); assertEquals("abs(0) should be 0.", 0, example.abs(0)); } /** * Test the Example.add() method. This also covers the code of the inner * class. */ public void testInnerClass() { Example example = new Example(); assertEquals("add(2, 3) should be 5.", 5, example.add(2, 3)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -