0

I would like to have my regression tests generated by Randoop 4.2 to be named (Something)RandoopTest.java, so I set the command line flag --regression-test-basename=RandoopTest. When I run Randoop, my regression tests all end in RandoopTest0.java (note the 0). For example, when I run the following command,

java -classpath C:\sandbox\TestJavaProject\bin;%RANDOOP_JAR%
        randoop.main.Main gentests
        --testclass=org.jaffa.datatypes.Currency
        --junit-package-name=org.jaffa.datatypes
        --junit-output-dir=C:\sandbox\TestJavaProject\src\test\java
        --regression-test-basename=CurrencyRandoopTest
        --time-limit=10
        --junit-reflection-allowed=false
        --flaky-test-behavior=DISCARD

I get two files generated, as shown by the console output:

Writing regression JUnit tests...
Created file C:\sandbox\TestJavaProject\src\test\java\org\jaffa\datatypes\CurrencyRandoopTest0.java
Created file C:\sandbox\TestJavaProject\src\test\java\org\jaffa\datatypes\CurrencyRandoopTestDriver.java
Wrote regression JUnit tests.

Is there an easy way to eliminate the 0? I'm curious as to why it is there. I've never noticed any other numbers besides 0 added to the class name. Currently, our maven scripts are designed to run JUit tests that end in "Test", so the 0 is a bother. (I know I can modify the scripts to automatically run JUnit tests that end in "Test0", but it would be nicer if I didn't have to.)

4

1 回答 1

1

Randoop在名为、等的文件中输出测试。默认情况下,每个编号文件中只放入500个。Randoop 通常会创建许多测试,并且将所有测试放在一个文件中会违反 Java 对文件大小的限制。...Test0,java...Test1.java

Randoop在一个文件名末尾没有数字的文件中输出一个运行所有测试的测试套件。...Test.java

Randoop 手册开头的示例显示了这些文件以及如何使用它们。

如果您从未见过 Randoop 输出超过 500 个测试,您可能需要调整Randoop的命令行参数,为其提供更多信息,以便它可以更有效地生成测试。

例子

作为文件的具体示例,请参见 directory build/working-directories/naive-collections-test/java/foo/bar/。在您运行 Randoop 自己的测试套件后,它将存在。

它包含以下文件:

NaiveRegression.java

NaiveRegression0.java
NaiveRegression1.java
NaiveRegression2.java

其中的内容NaiveRegression.java是:

@RunWith(Suite.class)
@Suite.SuiteClasses({ NaiveRegression0.class, NaiveRegression1.class, NaiveRegression2.class })
public class NaiveRegression {
}
于 2019-09-05T14:03:37.160 回答