Randoop使用

下载:https://randoop.github.io/randoop/

打开github,搜索randoop,点release获得zip文件,解压缩,将测试类放到randoop的jar所在目录

编译测试类

错误信息

Cannot find the Java compiler. Check that classpath includes tools.jar

解决:将%JAVA_HOME%\lib\tools.jar文件复制到%JAVA_HOME%.\jre1.8.0_121\lib\目录下

生成测试用例

java -Xmx3000m -classpath .;randoop-all-4.1.0.jar;Test1 randoop.main.Main gentests --testclass=Test1 --output-limit=100

测试类加入对称性错误让randoop自动生成检测错误代码的测试用例:

public void setName(String name) {
	if (this.name.equals(name) == name.equals(this.name))
		;
	else
        this.name = name;
  }

再次编译,生成测试用例:

将junit.jar和hamcrest-core.jar放入当前文件夹:

编译ErrorTest.java和运行检测错误的测试用例,结果提示代码中出错的具体方法:

java  -classpath  .;junit-4.12.jar;hamcrest-core-1.3.jar  org.junit.runner.JUnitCore  ErrorTest

编译RegressionTest.java和运行回归测试:

java  -classpath  .;junit-4.12.jar;hamcrest-core-1.3.jar  org.junit.runner.JUnitCore  RegressionTest

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值