My objective is to generate very basic unit tests for a lot of legacy code we are migrating to a new platform. (I know unit tests are not useful this way, but sometimes it happens). We are only blocked for covering percentage so it is good to go with basic tests in the methods we need, so going with an automatically generated tests will be the most efficient strategy.
I found RANDOOP https://randoop.github.io/randoop/ and start trying to make it work. However I found a problem, which in part is due to my almost zero knowledge of java ( I did something similar in .net with just a few clicks and in less than 4 hours).
I´m following official manual here https://randoop.github.io/randoop/manual/index.html#getting_randoop and the video of this guy who just makes it work https://www.youtube.com/watch?v=nPdb-72-EJY.
The Problem
Plain words the problem is the following error when I run this command
java -classpath 'C:\randoop-4.2.1\bin;C:\randoop-4.2.1\randoop-all-4.2.1.jar' randoop.main.Main gentests --testclass=ClassName
> Throwable thrown while handling command:
> java.lang.IllegalStateException: Cannot find the Java compiler. Check
> that classpath includes tools.jar java.lang.IllegalStateException:
> Cannot find the Java compiler. Check that classpath includes tools.jar
> at randoop.compile.SequenceCompiler.<init>(SequenceCompiler.java:64)
> at randoop.compile.SequenceCompiler.<init>(SequenceCompiler.java:48)
> at randoop.condition.SpecificationCollection.<init>(SpecificationCollection.java:82)
> at randoop.condition.SpecificationCollection.create(SpecificationCollection.java:102)
> at randoop.main.GenTests.handle(GenTests.java:279)
> at randoop.main.Main.nonStaticMain(Main.java:66)
> at randoop.main.Main.main(Main.java:30)
>
> Randoop failed. No sequences generated.
what is this above?
I run the command from console placed at the bin folder of randoop "installation" folder.
C:\randoop-4.2.1\bin is the folder where I unzipped Randoop download. Some weird thing is that none of the Randoop version downloads contains the bin folder, so I created it arbitrarily. I don't know if that is right or wrong, but I just did it.
At the beginning the video runs the following command, which is really basic and it worked ok on my system.
java -classpath .\randoop-4.2.1\randoop-all-4.2.1.jar randoop.main.Main help gentests
There is also a text file named myclasslist I don't understand why this guys never talk about. I don't have it.
I have Java 8 installed at c:\program files\jdk1.8.0_231
and the Paths and environment variables are set like this.
EDIT
In the video, the guy has the .java file in the randoop root folder. I don´t since I have a real project in intellij. i just found the classs file and copied it to bin folder.