Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems evosuite can not generate test cases with project containing springboot jpa #453

Open
swenker opened this issue May 21, 2023 · 0 comments

Comments

@swenker
Copy link

swenker commented May 21, 2023

Context

Please provide below a detailed introduction to the issue itself, and describe what you were doing when the issue happened. Or, what do you want to achieve?

Tests can not be generated. After investigation, I found when the jpa dedendency is removed, tests can be generated as expected.

There are also some errors in the log file:

[MASTER] 19:59:16.903 [pool-2-thread-1] ERROR TestSuiteGenerator - Problem for com.example.demo.rest.RestHelper. Full stack:
java.lang.IllegalArgumentException: null
at org.evosuite.shaded.org.objectweb.asm.ClassReader.(ClassReader.java:160)
at org.evosuite.shaded.org.objectweb.asm.ClassReader.(ClassReader.java:143)
at org.evosuite.shaded.org.objectweb.asm.ClassReader.(ClassReader.java:418)
at org.evosuite.setup.InheritanceTreeGenerator.analyzeClassStream(InheritanceTreeGenerator.java:238)
at org.evosuite.setup.InheritanceTreeGenerator.createFromClassPath(InheritanceTreeGenerator.java:101)
at org.evosuite.setup.DependencyAnalysis.initInheritanceTree(DependencyAnalysis.java:77)
at org.evosuite.setup.DependencyAnalysis.analyzeClass(DependencyAnalysis.java:131)
at org.evosuite.TestSuiteGenerator.initializeTargetClass(TestSuiteGenerator.java:110)
at org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:130)
at org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:145)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

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. add jpa dependency

    org.springframework.boot
    spring-boot-starter-data-jpa

  2. mvn clean compile evosuite:generate

EvoSuite Arguments

Please provide the whole EvoSuite commmand you executed (if relevant)

Current Result

Please describe here below the current result you got (if relevant)
[if relevant, include a screenshot]

                               mvn clean compile evosuite:generate

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.example:demo-simple >-----------------------
[INFO] Building demo-simple 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ demo-simple ---
[INFO] Deleting E:\projects-review\demo-simple\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ demo-simple ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory E:\projects-review\demo-simple\src\main\resources
[INFO] skip non existing resourceDirectory E:\projects-review\demo-simple\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ demo-simple ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to E:\projects-review\demo-simple\target\classes
[INFO]
[INFO] >>> evosuite-maven-plugin:1.2.0:generate (default-cli) > compile @ demo-simple >>>
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ demo-simple ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory E:\projects-review\demo-simple\src\main\resources
[INFO] skip non existing resourceDirectory E:\projects-review\demo-simple\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ demo-simple ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to E:\projects-review\demo-simple\target\classes
[INFO]
[INFO] <<< evosuite-maven-plugin:1.2.0:generate (default-cli) < compile @ demo-simple <<<
[INFO]
[INFO]
[INFO] --- evosuite-maven-plugin:1.2.0:generate (default-cli) @ demo-simple ---
[INFO] Going to generate tests with EvoSuite
[INFO] Total memory: 800mb
[INFO] Time per class: 2 minutes
[INFO] Number of used cores: 1
[INFO] Target: E:\projects-review\demo-simple\target\classes
[INFO] Basedir: E:\projects-review\demo-simple
[INFO] Started spawn process manager on port 4587
[INFO] * EvoSuite 1.2.0
[INFO] Registered remote process from /127.0.0.1:4588
[INFO] Going to execute 4 jobs
[INFO] Estimated completion time: 8 minutes, by 2023-05-21T19:24:15.172
[INFO] Going to start job for: com.example.demo.service.TimePeriod. Expected to end in 120 seconds, by 2023-05-21T19:18:15.678
[INFO] [MASTER] 19:25:15.133 [main] ERROR JobExecutor - The jobs did not finish in time
[INFO] * Updating database to com.example.demo.service.TimePeriod
[INFO] * Updating database to com.example.demo.rest.RestHelper
[INFO] * Updating database to com.example.demo.rest.resp.Greeting
[INFO] * Updating database to com.example.demo.rest.param.GreetingStyle
[INFO] === CTG run results ===
[INFO] Removed test suites: 0
[INFO] New test suites: 0
[INFO] Missing classes:
[INFO] com.example.demo.service.TimePeriod
[INFO] com.example.demo.rest.RestHelper
[INFO] com.example.demo.rest.resp.Greeting
[INFO] com.example.demo.rest.param.GreetingStyle
[INFO] WARN: failed to generate tests for 4 classes out of 4
[INFO] Stopping spawn process manager
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Expected result

Please describe here below what should be the expected behaviour (if relevant)

Additional info

Please add any information of interest here below

std_err_CLIENT.log
std_err_MASTER.log

full maven project: demo-simple.zip

dd

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.9</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<groupId>com.example</groupId>
	<artifactId>demo-simple</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-simple</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>1.8</java.version>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
<!--		<evosuiteVersion>1.2.0</evosuiteVersion>-->
		<evosuiteVersion>1.0.6</evosuiteVersion>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>

		<dependency>
			<groupId>org.evosuite</groupId>
			<artifactId>evosuite-standalone-runtime</artifactId>
			<version>${evosuiteVersion}</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/junit/junit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.13.2</version>
			<scope>test</scope>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<properties>
						<property>
							<name>listener</name>
							<value>org.evosuite.runtime.InitializingListener</value>
						</property>
					</properties>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.evosuite.plugins</groupId>
				<artifactId>evosuite-maven-plugin</artifactId>
				<version>${evosuiteVersion}</version>
				<executions>
					<execution>
						<goals>
							<goal> prepare </goal>
						</goals>
						<phase> process-test-classes </phase>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>

</project>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant