Feed4Junit官方地址:
http://databene.org/feed4junit.html
Feed4Junit自动生成测试数据:
Feed4JUnit 1.1.1 发布了,该版本支持从 CSV 文件中导入完整的 JavaBean 图表。
利用Feed4JUnit能够很方便用随机但校验过的数据执行冒烟测试来提高代码 代码覆盖率和发现由非常特殊的数据结构产生的Bug。此外还可以利用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; } } }