First, go to github and download the randoop.jar package to the local directory.
Here I chose randoop-all-4.1.0.jar and installed it to
This directory is arbitrary
Then go to configure the system environment variables
Add the path of randoop-all-4.1.0.jar in Path C:\worktools\randoop-4.1.0\randoop-all-4.1.0.jar
Then add two system variables
Here, I stepped on a pit
That is what the official randoop documentation says
When there are multiple java versions, in the environment variable Path, put %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; at the top
(Anyway, as long as it is in front of C:\Program Files (x86)\Common Files\Oracle\Java\javapath;)
Here randoop official website has said (ctrl+f search for compile, the last one or so)
Otherwise, it will report an error that the java compiler cannot be found
Cannot find the Java compiler. Check that classpath includes tools.jar
Of course, it is also possible to put the tools.jar package in the lib directory of the jdk folder into the lib directory of jre in the jdk folder
Try them all.
This pit has pitted me for a long time. I would like to thank a big man surnamed Liu for his guidance during class.
Probably this will be able to install it.
Then just write a class
What I wrote here is a triangle test class
/**
* @author codersan
* @date 2018/12/10 12:50
* @introduction
*/
public class test1 {
double a = 0;
double b = 0;
double c = 0;
public test1() {
}
public test1(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
public double getA() {
return a;
}
public void setA(double a) {
this.a = a;
}
public double getB() {
return b;
}
public void setB(double b) {
this.b = b;
}
public double getC() {
return c;
}
public void setC(double c) {
this.c = c;
}
public String dengyao(){
if(a<=0||b<=0||c<=0) return "side can no be 0";
if(a+b<=c||a+c<=b||b+c<=a) return "is not triangle";
if(a==b ||a==c||b==c){
if(a!=b||a!=c||b!=c)return "dengyao triangle";
return "dengbian triangle";
}
return "putong triangle";
}
}
Of course, you can write any one by yourself
Then compile this .java file into a .class file
Put this file and the randoop.jar package in the same directory, other things are fine, but it's convenient
Then open cmd and jump to the directory
Run the following command
java -ea -classpath .;%RANDOOP_JAR% randoop.main.Main gentests --testclass=test1 --time-limit=60
One thing to note here is that there is no-in the previous version of timelimit. Timelimie is replaced by time-limit, which is also a pit
Approximate results of running
Then it will be generated in the corresponding directory
At this point, the general process of using randoop is over
If there are more pitfalls, I hope everyone can write their own methods on the blog in time while solving them.
After all, many people like me don’t like to go abroad to find