一、EvoSuite简介
EvoSuite 是由 Sheffield 等大学联合开发的一种开源工具,用于自动生成测试用例集,生成的测试用例均符合 Junit的标准,可直接在 Junit 中运行。
通过使用此自动测试工具能够在保证代码覆盖率的前提下极大地提高测试人员的开发效率。但是只能辅助测试,并不能完全取代人工,测试用例的正确与否还需人工判断。
1.1 核心功能:
对于指定类,生成 Junit4 类型的单测代码。------Generation of JUnit 4 tests for the selected classes
根据不同覆盖指标调整生成的用例,例如 行覆盖,分支覆盖,输出覆盖等。------Optimization of different coverage criteria, like lines, branches, outputs and mutation testing
单测用例最小化,只有对覆盖率有贡献的单测用例才会被保留。------Tests are minimized: only the ones contributing to achieve coverage are retained
生成的单测用例中包含 Junit 断言。------Generation of JUnit asserts to capture the current behavior of the tested classes
测试运行在 sandbox 中。------Tests run in a sandbox to prevent potentially dangerous operations
虚拟文件系统。------Virtual file system
虚拟网络。------Virtual network
二、使用