exampletest.java
来自「这个工具用于对JAVA的类文件进行覆盖率的测试」· Java 代码 · 共 61 行
JAVA
61 行
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 + =
减小字号Ctrl + -
显示快捷键?