首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Feed4Junit的容易使用(一)

2013-12-02 
Feed4Junit的简单使用(一)package com.easyway.feed4junitimport org.databene.benerator.anno.Coverage

Feed4Junit的简单使用(一)
package com.easyway.feed4junit;import org.databene.benerator.anno.Coverage;import org.databene.benerator.anno.InvocationCount;import org.databene.feed4junit.Feeder;import org.junit.Test;import org.junit.runner.RunWith;/** * 利用Feed4JUnit能够很方便用随机但校验过的数据执行冒烟测试来提高代码 代码覆盖率和发现由非常特殊的数据结构产生的Bug。 * 此外还可以利用Feed4JUnit轻松定义等价类测试。 * @author longgangbai * */@RunWith(Feeder.class)public class AutoProductDataTest { @Test @Coverage @InvocationCount(100) public void testAdd(int param1, int param2) throws Exception { try { int result = MyUtil.add(param1, param2); } catch (Exception e) { // accept application exceptions, fail on runtime exceptions // like NullPointerException if (e instanceof RuntimeException) throw e; } } private static class MyUtil{ public static int add(int num1 ,int num2 ){ return num1+num2; } }}

?

热点排行