EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
832 stars 341 forks source link

Evosuite Maven plugin with Java 11 #369

Open rahulahuja352 opened 3 years ago

rahulahuja352 commented 3 years ago

Context

I have a working project with Java 8, integrated with Evosuite 1.0.6 plugin. I have to upgrade my project to Java 11. I have upgraded to evosuite 1.1.0 jar and evosuite 1.1.0 standalone-runtime-jar. As maven plugin is not available for evosuite 1.1.0 , I have taken the source code from github https://github.com/EvoSuite/evosuite/releases/tag/v1.1.0 and build the maven plugin locally and used the jar in our project to generate test cases using mvn evosuite:generate. I am getting classnotfound excepton for all the classes in my project.

Steps to Reproduce

Please break down here below all the needed steps to reproduce the issue. [If possible, please upload an example of the project you are generating tests for.]

  1. Update pom.xml to evosuite 1.1.0 dependencies.
  2. download evosuite source code from github, build the code to get the maven compiler plugin 1.1.0 for evosuite.
  3. use the plugin and evosuite jars in our project to generate test cases.

EvoSuite Arguments

mvn compile -DmemoryInMB=2000 -Dcores=2 -Dcuts=com.dupont.foundation.core.slingmodel.topiclist.NewsCarouselModel -DtargetFolder=src/test evosuite:generate evosuite:export

This is the command I used to generate test cases for NewCaraouselModel class in my project.

Current Result

[INFO] java.lang.ClassNotFoundException: com.dupont.foundation.core.slingmodel.topiclist.NewsCarouselModel [INFO] at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) [INFO] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) [INFO] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) [INFO] at java.base/java.lang.Class.forName0(Native Method) [INFO] at java.base/java.lang.Class.forName(Class.java:315) [INFO] at org.evosuite.continuous.project.ProjectAnalyzer.getCutsToAnalyze(ProjectAnalyzer.java:169) [INFO] at org.evosuite.continuous.project.ProjectAnalyzer.analyze(ProjectAnalyzer.java:200) [INFO] at org.evosuite.continuous.ContinuousTestGeneration.execute(ContinuousTestGeneration.java:157) [INFO] at org.evosuite.executionmode.Continuous.execute(Continuous.java:131) [INFO] at org.evosuite.EvoSuite.parseCommandLine(EvoSuite.java:346) [INFO] at org.evosuite.EvoSuite.main(EvoSuite.java:115) [INFO] There is no class to test in the chosen project [INFO] Target: /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes [INFO] Prefix: '' [INFO] Stopping spawn process manager [INFO] [INFO] --- evosuite-maven-plugin:1.1.0:export (default-cli) @ dupont-foundation-core --- [INFO] Exporting tests [INFO] Nothing to export [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS

Expected result

Expected result is it should be able to generate tests.

Please let me know if have done anything wrong.

jose commented 3 years ago

Hi @rahulahuja352,

The info message is clear There is no class to test in the chosen project. Thus, EvoSuite is not able to find the class com.dupont.foundation.core.slingmodel.topiclist.NewsCarouselModel. What's the output of

find /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes

?

-- Best, Jose

rahulahuja352 commented 3 years ago

Thanks for the response Jose. Above command shared by you gives all the class files. Below is just a snapshot :

find /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/META-INF /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/META-INF/readme.txt /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/OSGI-INF /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/OSGI-INF/readme.txt /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/DccFormServiceServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/ResourcesDataServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/UserDetails.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/ReferencesInteractiveMapServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/DuplicateUserServiceServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/TagsLocalizationServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/ListingServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/CampaignDataSubmitServlet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/FAQDataServelet.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/servlet/PageResourcePathsServlet.class

There is no issue in finding class files. Project builds successfully. Same command used to work earlier. Nothing has changed , just the Evosuite version.

Please help me, we are struggling

jose commented 3 years ago

As you can see, there is no NewsCarouselModel class under /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes. Thus, no surprise EvoSuite can't find it.

rahulahuja352 commented 3 years ago

it is there...I didn't copied all the lines as it was huge...

/Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/slingmodel/videogallery/VideoGalleryModel.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/slingmodel/topiclist /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/slingmodel/topiclist/NewsEventsResultsModel$1.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/slingmodel/topiclist/NewsCarouselModel.class /Users/mymac/Downloads/dupont-foundation-platform-dupont-foundation-6.5-1.5.0/core/target/classes/com/dupont/foundation/core/slingmodel/topiclist/UpcomingNewsEventsModel.class

jose commented 3 years ago

Ok. How did you 'download evosuite source code from github, build the code to get the maven compiler plugin 1.1.0 for evosuite' ? I will need the exact set of commands you used, please.

rahulahuja352 commented 3 years ago

I downloaded Evosuite source code from GitHub https://github.com/EvoSuite/evosuite/releases/tag/v1.1.0 and run mvn clean install on the main folder. Some test cases were failing so I just did mvn clean install -DskipTests=true After this, just went into the plugins folder and ran the same command.