对于可执行的jar evosuite-1.1.0.jar,可以在命令行使用jave -jar执行它
然而,每次进入到jar包所在的目录,有点繁琐,这个命令看上去也有点点长。
那么我们可以设置环境变量EVOSUITE来取代这个命令,也即
set EVOSUITE=java -jar C:/Libraries/maven-3.5.0/lib/evosuite-1.1.0.jar
打印看看设置好了没
(注意:这个设置是临时的,如果当前的cmd关闭,下一次打开时需要重新设置)
用一下试试!
下面随意找个类生成一下测试组件
%EVOSUITE% -class org.apache.commons.lang3.ArrayUtils -projectCP target/classes
命令行输出如下
* EvoSuite 1.1.0
* Going to generate test cases for class: org.apache.commons.lang3.ArrayUtils
* Starting Client-0
* Connecting to master process on port 21083
* Analyzing classpath:
- target/classes
* Finished analyzing classpath
* Generating tests for class org.apache.commons.lang3.ArrayUtils
* Test criteria:
- Line Coverage
- Branch Coverage
- Exception
- Mutation testing (weak)
- Method-Output Coverage
- Top-Level Method Coverage
- No-Exception Top-Level Method Coverage
- Context Branch Coverage
[Progress:> 0%] [Cov:> 0%]* Total number of test goals for DYNAMOSA: 5568
* Using seed 1695175201821
* Starting evolution
* Initial Number of Goals in DynaMOSA = 1447 / 5568
[MASTER] 10:00:04.999 [logback-2] ERROR TestCluster - Failed to check cache for java.util.AbstractMap<K, V>.SimpleEntry<K, V> : Type points to itself
[MASTER] 10:00:05.000 [logback-2] ERROR TestCluster - Failed to check cache for java.util.AbstractMap<K, V>.SimpleImmutableEntry<K, V> : Type points to itself
[Progress:===============> 50%] [Cov:===============================> 89%][MASTER] 10:00:35.851 [logback-2] ERROR TestCluster - Failed to check cache for java.util.Comparator<T> : Type points to itself
[Progress:==============================100%] [Cov:===============================> 89%]
* Search finished after 65s and 407 generations, 232971 statements, best individual has fitness: 362.0
[MASTER] 10:01:12.788 [logback-1] WARN TimeController - Phase SEARCH lasted too long, 7 seconds more than allowed.
* Minimizing test suite
[MASTER] 10:02:20.325 [logback-1] WARN TestSuiteMinimizer - Minimization timeout. Roll back to original test suite
* Going to analyze the coverage criteria
* Coverage analysis for criterion LINE
* Coverage of criterion LINE: 99%
* Total number of goals: 1225
* Number of covered goals: 1211
* Coverage analysis for criterion BRANCH
* Coverage of criterion BRANCH: 99%
* Total number of goals: 1123
* Number of covered goals: 1117
* Coverage analysis for criterion EXCEPTION
* Coverage of criterion EXCEPTION: 100%
* Total number of goals: 57
* Number of covered goals: 57
* Coverage analysis for criterion WEAKMUTATION
* Coverage of criterion WEAKMUTATION: 86%
* Total number of goals: 1065
* Number of covered goals: 912
* Coverage analysis for criterion OUTPUT
* Coverage of criterion OUTPUT: 84%
* Total number of goals: 592
* Number of covered goals: 498
* Coverage analysis for criterion METHOD
* Coverage of criterion METHOD: 100%
* Total number of goals: 220
* Number of covered goals: 220
* Coverage analysis for criterion METHODNOEXCEPTION
* Coverage of criterion METHODNOEXCEPTION: 100%
* Total number of goals: 220
* Number of covered goals: 219
* Coverage analysis for criterion CBRANCH
* Coverage of criterion CBRANCH: 96%
* Total number of goals: 1123
* Number of covered goals: 1083
* Generated 1192 tests with total length 14308
* Resulting test suite's coverage: 89% (average coverage for all fitness functions)
* Generating assertions
[MASTER] 10:03:14.482 [logback-1] WARN SimpleMutationAssertionGenerator - Assertion minimization is taking too long (0.7501833333333333% of time used, but only 245/1192 tests minimized), falling back to using all assertions
* Resulting test suite's mutation score: 40%
* Compiling and checking tests
* Writing tests to file
* Writing JUnit test case 'ArrayUtils_ESTest' to evosuite-tests
* Done!* Computation finished