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; } }}
?