我尝试使用新的 EvoSuite (0.1.1),但是,它失败了,但有以下例外。我尝试了几个课程,但结果通常是相同的。有时它能够毫无例外地完成。我正在使用带有 Java 8 的 Ubuntu 14.04 64 位。-projectCP 参数是正确的。我附上了更简单的一代和 CUT 的输出。
命令:
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
输出:
* 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]
班级代码:
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;
}
}