I'm trying to generate Java unit test cases using Randoop. Suppose I've a class named ABC. Inside class ABC, I've instantiated the Logger class of log4j as a field and this field is being accessed by a method. I've listed class ABC in myClasses.txt. Now while running the gentests command, I'm getting noClassDefFound error for the Logger instance. Please help if we're missing on something?
Why am I unable to generate code using Randoop where classes of other Jars are involved?
474 Views Asked by Damini Kala At
2
There are 2 best solutions below
0
On
The command line for running Randoop includes a classpath argument. Is the log4j jar file included in the classpath provided to Randoop? Your command line should look something like:
java -classpath %RANDOOP_JAR%;%ABC_HOME%;%LOG4J_JAR% randoop.main.Main gentests --testclass=ABC
where %ABC_HOME% is an environment variable indicating where your ABC class resides, and %LOG4J_JAR% refers to the location of your log4j jar file. (This is in Windows notation. Linux paths use ":" separators rather than ";" separators.) And of course you don't need to use environment variables. You can just plug in the appropriate paths.
You have to put Logger class also in myClasses.txt. Also provide log4j properties file in java -Dlog4j.configuration=file:...