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

Unable to produce test case, and no valid error message #242

Open zyou1986 opened 5 years ago

zyou1986 commented 5 years ago

1.My question Some projects can generate test cases by evosuite, but some don't work(E.g: git@github.com:zyou1986/riskcontrol.git), I don't know where the problem is.

2.Error message: 2.1 in command line: (I guarantee that the .KieService file path is correct.)

mvn compile -DmemoryInMB=2000 -Dcores=2 -Dcuts=com.example.riskcontrol.service.KieService -DtargetFolder=src/test evosuite:generate evosuite:export

[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building riskcontrol 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [WARNING] The POM for org.apache.httpcomponents:httpclient:jar:4.5.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for commons-lang:commons-lang:jar:2.6 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for org.apache.httpcomponents:httpcore:jar:4.4.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for org.hamcrest:hamcrest-core:jar:1.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ riskcontrol --- [WARNING] The POM for commons-cli:commons-cli:jar:1.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 7 resources [INFO] [INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ riskcontrol --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] >>> evosuite-maven-plugin:1.0.6:generate (default-cli) > compile @ riskcontrol >>> [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ riskcontrol --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource [INFO] Copying 7 resources [INFO] [INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ riskcontrol --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] <<< evosuite-maven-plugin:1.0.6:generate (default-cli) < compile @ riskcontrol <<< [INFO] [INFO] [INFO] --- evosuite-maven-plugin:1.0.6:generate (default-cli) @ riskcontrol --- [WARNING] The POM for commons-logging:commons-logging:jar:1.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [INFO] Going to generate tests with EvoSuite [INFO] Total memory: 2000mb [INFO] Time per class: 2 minutes [INFO] Number of used cores: 2 [INFO] Specified classes under test: com.example.riskcontrol.service.KieService [INFO] Target: /Users/mileszhou/Downloads/riskcontrol-master/target/classes [INFO] Basedir: /Users/mileszhou/Downloads/riskcontrol-master [INFO] Started spawn process manager on port 64926 [WARNING] The POM for org.apache.httpcomponents:httpclient:jar:4.3.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for org.apache.httpcomponents:httpcore:jar:4.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [INFO] SLF4J: Class path contains multiple SLF4J bindings. [INFO] SLF4J: Found binding in [jar:file:/Users/mileszhou/.m2/repository/org/evosuite/evosuite-master/1.0.6/evosuite-master-1.0.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] [INFO] SLF4J: Found binding in [jar:file:/Users/mileszhou/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] [INFO] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. [INFO] SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] [INFO] EvoSuite 1.0.6 [INFO] Registered remote process from /127.0.0.1:64927 [INFO] Going to execute 1 jobs [INFO] Estimated completion time: 1 minutes, by 2018-12-06T19:52:20.676 [INFO] Going to start job for: com.example.riskcontrol.service.KieService. Expected to end in 60 seconds, by 2018-12-06T19:52:20.710 [INFO] Registered remote process from /127.0.0.1:64928 [INFO] Registered remote process from /127.0.0.1:64935 [INFO] Completed job. Left: 0 [INFO] Updating database to com.example.riskcontrol.service.KieService [INFO] === CTG run results === [INFO] Removed test suites: 0 [INFO] New test suites: 0 [INFO] WARN: failed to generate tests for com.example.riskcontrol.service.KieService [INFO] Stopping spawn process manager [INFO] [INFO] --- evosuite-maven-plugin:1.0.6:export (default-cli) @ riskcontrol --- [INFO] Exporting tests [INFO] Nothing to export [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------

2.1 in log: std_err_CLIENT.log: [MASTER] 19:51:23.288 [pool-2-thread-1] ERROR TestSuiteGenerator - Problem for com.example.riskcontrol.service.KieService. Full stack: java.lang.NoSuchMethodError: com.thoughtworks.xstream.XStream.setupDefaultSecurity(Lcom/thoughtworks/xstream/XStream;)V at org.evosuite.setup.InheritanceTreeGenerator.readJDKData(InheritanceTreeGenerator.java:444) at org.evosuite.setup.InheritanceTreeGenerator.createFromClassPath(InheritanceTreeGenerator.java:82) 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)

std_err_MASTER.log: [MASTER] 19:51:23.449 [main] ERROR SearchStatistics - No statistics has been saved because EvoSuite failed to generate any test case [MASTER] 19:51:23.554 [main] ERROR TestGeneration - failed to write statistics data

std_out_MASTER.log: EvoSuite 1.0.6

3.dependency dependencie:

org.evosuite.plugins evosuite-maven-plugin 1.0.6 org.evosuite evosuite-standalone-runtime 1.0.6 test junit junit 4.12 test

pom.xml:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>riskcontrol</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>riskcontrol</name>
    <description>risk control</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-test</artifactId>-->
            <!--<scope>test</scope>-->
        <!--</dependency>-->

        <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
        <!--<scope>provided</scope>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.39</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.23</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.drools</groupId>
            <artifactId>drools-compiler</artifactId>
            <version>6.4.0.Final</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.kie</groupId>
            <artifactId>kie-ci</artifactId>
            <version>6.4.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongodb-driver</artifactId>
            <version>3.2.2</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.2</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.15</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.evosuite</groupId>
            <artifactId>evosuite-standalone-runtime</artifactId>
            <version>1.0.6</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.5.v20170502</version>
                <configuration>
                    <systemProperties>
                        <!--<systemProperty>-->
                            <!--<name>project.home</name>-->
                            <!--<value>../src/maincom/example/riskcontrol</value>-->
                        <!--</systemProperty>-->
                        <systemProperty>
                            <name>jetty.http.port</name>
                            <value>8323</value>
                        </systemProperty>
                    </systemProperties>
                    <!--<webApp>-->
                        <!--<contextPath>/com.example.riskcontrol</contextPath>-->
                    <!--</webApp>-->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.evosuite.plugins</groupId>
                <artifactId>evosuite-maven-plugin</artifactId>
                <version>1.0.6</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <!-- put your configurations here -->
                </configuration>
            </plugin>
        </plugins>
    </build>
    <pluginRepositories>
        <pluginRepository>
            <id>EvoSuite</id>
            <name>EvoSuite Repository</name>
            <url>http://www.evosuite.org/m2</url>
        </pluginRepository>
    </pluginRepositories>

</project>
buiatte commented 5 years ago

+1

Facing the same issue with:

suntingme commented 4 years ago

this is because the evosuite depends on xtream 1.4.10, see in the file evosuite/pom.xml at line 424.

try to check your program, maybe it depends on the version lower than 1.4.10

RamyasmrutiP commented 4 years ago

facing same issue, can some one please help, this is urgent master.log [MASTER] 23:39:35.093 [main] ERROR TestGeneration - Not possible to access to clients. Clients' state: Terminated with exit status 1. Master registry port: 4810 [MASTER] 23:39:35.113 [main] ERROR SearchStatistics - No statistics has been saved because EvoSuite failed to generate any test case [MASTER] 23:39:35.214 [main] ERROR TestGeneration - failed to write statistics data client.log [MASTER] 23:38:59.565 [main] ERROR ClientServices - Failed to register client services java.rmi.ConnectException: Connection refused to host: 10.221.0.150; nested exception is: java.net.ConnectException: Connection timed out: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) ~[na:1.8.0_171] at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216) ~[na:1.8.0_171] at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202) ~[na:1.8.0_171] at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:338) ~[na:1.8.0_171] at sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:147) ~[na:1.8.0_171] at org.evosuite.rmi.ClientServices.registerServices(ClientServices.java:67) ~[evosuite-master-1.0.6.jar:1.0.6] at org.evosuite.ClientProcess.run(ClientProcess.java:82) [evosuite-master-1.0.6.jar:1.0.6] at org.evosuite.ClientProcess.main(ClientProcess.java:203) [evosuite-master-1.0.6.jar:1.0.6] Caused by: java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) ~[na:1.8.0_171] at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) ~[na:1.8.0_171] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_171] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_171] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_171] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_171] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_171] at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_171] at java.net.Socket.connect(Socket.java:538) ~[na:1.8.0_171] at java.net.Socket.(Socket.java:434) ~[na:1.8.0_171] at java.net.Socket.(Socket.java:211) ~[na:1.8.0_171] at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40) ~[na:1.8.0_171] at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148) ~[na:1.8.0_171] at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613) ~[na:1.8.0_171] ... 7 common frames omitted [MASTER] 23:38:59.602 [main] ERROR ClientProcess - Error when generating tests for: tutorial.Stack with seed 1586282918429. Configuration id : default java.lang.RuntimeException: Could not connect to master process on port 4810 at org.evosuite.ClientProcess.run(ClientProcess.java:87) ~[evosuite-master-1.0.6.jar:1.0.6] at org.evosuite.ClientProcess.main(ClientProcess.java:203) ~[evosuite-master-1.0.6.jar:1.0.6]