简体   繁体   English

使用EvoSuite时发生NullPointerException

[英]NullPointerException when using EvoSuite

I tried to use the new EvoSuite (0.1.1), however, it has failed with the exception below. 我尝试使用新的EvoSuite(0.1.1),但由于以下异常而失败。 I have tried with several classes, but the result is usually the same. 我尝试了几个类,但结果通常是相同的。 Sometimes it is able to finish without an exception. 有时它可以毫无例外地完成。 I am using Ubuntu 14.04 64-bit with Java 8. The -projectCP parameter is correct. 我正在使用Java 8的Ubuntu 14.04 64位。-projectCP参数正确。 I have attached the output of a simpler generation and the CUT. 我已经附上了更简单的一代和CUT的输出。

Command: 命令:

java -jar ../../sette-tool/test-generator-tools/evosuite/evosuite.jar -projectCP build -generateTests -Dsearch_budget=10 -class hu.bme.mit.sette.snippets._1_basic.B2_conditionals.B2a_IfElse

Output: 输出:

* EvoSuite 
* Going to generate test cases for class: hu.bme.mit.sette.snippets._1_basic.B2_conditionals.B2a_IfElse
* Starting client
* Connecting to master process on port 12480
* Analyzing classpath: 
  - build
* Finished analyzing classpath
* Generating tests for class hu.bme.mit.sette.snippets._1_basic.B2_conditionals.B2a_IfElse
* Test criteria:
  - Line Coverage
  - Branch Coverage
  - Exception
  - Mutation testing (weak)
  - Method-Output Coverage
  - Top-Level Method Coverage
* Setting up search algorithm for individual test generation
* Total number of test goals: 
  - Line 55
  - Branch 82
  - Exception 0
  - MutationFactory 333
  - Output 18
  - Method 6
* Total number of test goals: 494
* Budget: 10

! Budget exceeded
* GA-Budget:
    - MaxTime :               1,431,415,037 / 10           Finished!
    - GlobalTime :                      16 / 600         
! #Goals that were not covered: 125
* Search finished after 14s, 11 statements, best individual has fitness 145.43707410246085
* Covered 369/494 goals
* Coverage of criterion LINE: 73%
* Number of covered goals: 40
* Coverage of criterion BRANCH: 77%
* Number of covered goals: 63
* Coverage of criterion EXCEPTION: 100% (no goals)
* Coverage of criterion WEAKMUTATION: 74%
* Number of covered goals: 248
* Coverage of criterion OUTPUT: 67%
* Number of covered goals: 12
* Coverage of criterion METHOD: 100%
* Number of covered goals: 6
* Resulting test suite: 2 tests, length 37
* Computation finished
[MASTER] 09:17:17.601 [pool-1-thread-2] ERROR ClientNodeImpl - Error when generating tests for: hu.bme.mit.sette.snippets._1_basic.B2_conditionals.B2a_IfElse with seed 1431415019886. Configuration id : null
java.lang.NullPointerException: null
    at org.evosuite.ga.Chromosome.getNumOfNotCoveredGoals(Chromosome.java:415) ~[evosuite.jar:na]
    at org.evosuite.statistics.SearchStatistics$IBranchGoalsSequenceOutputVariableFactory.getValue(SearchStatistics.java:517) ~[evosuite.jar:na]
    at org.evosuite.statistics.SearchStatistics$IBranchGoalsSequenceOutputVariableFactory.getValue(SearchStatistics.java:509) ~[evosuite.jar:na]
    at org.evosuite.statistics.SequenceOutputVariableFactory.update(SequenceOutputVariableFactory.java:39) ~[evosuite.jar:na]
    at org.evosuite.statistics.SearchStatistics.currentIndividual(SearchStatistics.java:159) ~[evosuite.jar:na]
    at org.evosuite.rmi.service.MasterNodeImpl.evosuite_collectStatistics(MasterNodeImpl.java:145) ~[evosuite.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) ~[na:1.8.0_45]
    at sun.rmi.transport.Transport$1.run(Transport.java:200) ~[na:1.8.0_45]
    at sun.rmi.transport.Transport$1.run(Transport.java:197) ~[na:1.8.0_45]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_45]
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196) ~[na:1.8.0_45]
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) ~[na:1.8.0_45]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) ~[na:1.8.0_45]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$241(TCPTransport.java:683) ~[na:1.8.0_45]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$8/1383432533.run(Unknown Source) ~[na:na]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_45]
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) ~[na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276) ~[na:1.8.0_45]
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253) ~[na:1.8.0_45]
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162) ~[na:1.8.0_45]
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194) ~[na:1.8.0_45]
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148) ~[na:1.8.0_45]
    at com.sun.proxy.$Proxy9.evosuite_collectStatistics(Unknown Source) ~[na:na]
    at org.evosuite.rmi.service.ClientNodeImpl.updateStatistics(ClientNodeImpl.java:219) ~[evosuite.jar:na]
    at org.evosuite.statistics.StatisticsSender.sendIndividualToMaster(StatisticsSender.java:46) ~[evosuite.jar:na]
    at org.evosuite.statistics.StatisticsSender.executedAndThenSendIndividualToMaster(StatisticsSender.java:76) ~[evosuite.jar:na]
    at org.evosuite.TestSuiteGenerator.generateTests(TestSuiteGenerator.java:470) ~[evosuite.jar:na]
    at org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:252) ~[evosuite.jar:na]
    at org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) ~[evosuite.jar:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]

Code of the class: 类的代码:

public final class B1b_Constants {
    private B1b_Constants() {
        throw new UnsupportedOperationException("Static class");
    }

    public static final boolean CONST_BOOLEAN = true;
    public static final byte CONST_BYTE = 123;
    public static final short CONST_SHORT = 12345;
    public static final int CONST_INT = 1234567890;
    public static final long CONST_LONG = 1234567890123456789L;
    public static final float CONST_FLOAT = 12345.67890f;
    public static final double CONST_DOUBLE = 1.2345678e90;
    public static final char CONST_CHAR = 'C';

    public static boolean constBoolean() {
        return B1b_Constants.CONST_BOOLEAN;
    }

    public static byte constByte() {
        return B1b_Constants.CONST_BYTE;
    }

    public static short constShort() {
        return B1b_Constants.CONST_SHORT;
    }

    public static int constInt() {
        return B1b_Constants.CONST_INT;
    }

    public static long constLong() {
        return B1b_Constants.CONST_LONG;
    }

    public static float constFloat() {
        return B1b_Constants.CONST_FLOAT;
    }

    public static double constDouble() {
        return B1b_Constants.CONST_DOUBLE;
    }

    public static char constChar() {
        return B1b_Constants.CONST_CHAR;
    }
}

A NPE is usually a bug in the tool. NPE通常是该工具中的错误。 However, I could not reproduce your issue on my machine (a Mac 10.10). 但是,我无法在我的机器(Mac 10.10)上重现您的问题。 Note that EvoSuite is currently targeted for Java 7. Wondering if you are encountering just some side effects (eg handling of RMI) of Java 8 here... (or its JVM built for Ubuntu). 请注意,EvoSuite当前针对Java7。不知道您是否在这里遇到Java 8(或为Ubuntu构建的JVM)的某些副作用(例如RMI处理)。

You might try to run with -Dnew_statistics=false and see if you still get the same issue. 您可以尝试使用-Dnew_statistics=false运行,看看是否仍然遇到相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM