I have generated tests that provide %100 coverage!
Get started.
git clone https://github.com/CSC-DevOps/TestGeneration.git
cd TestGeneration
npm install
Useful resource for istanbul.
You can run the local version as follows:
node_modules/.bin/istanbul cover test.js
node_module\.bin\istanbul cover test.js (Windows)
To install istanbul globally, saving some keystrokes, you can do the following:
npm install istanbul -G
You'll get a high level report as follows (a more detailed report will be stored in coverage/
):
=============================== Coverage summary =============================== Statements : 80% ( 4/5 ) Branches : 50% ( 1/2 ) Functions : 100% ( 1/1 ) Lines : 100% ( 4/4 ) ================================================================================
Run node main.js
to generate test.js
. The code under test is subject.js
.
-
- Use the
mock-fs
framework to generate a fake file system to help improve coverage.
- Use the
-
- Use the
faker
framework to generate a fake phone number to help improve coverage.
- Use the
-
- Extend the constraint discovery code to handle
>
and<
.
- Extend the constraint discovery code to handle
-
- Use clues in the code to automate the process of including file system, phone number mocking without manual injection.
open coverage/lcov-report/TestGeneration/subject.js.html
Download randoop:
wget https://randoop.googlecode.com/files/randoop.1.3.4.jar
Sample execution to generate tests for all classes in the java.util.Collections namespace (Need Java 7):
java -classpath randoop.1.3.4.jar randoop.main.Main gentests --testclass=java.util.TreeSet --testclass=java.util.Collections --timelimit=60
This will create a file RandoopTest.java
, which contains a test driver, and RandoopTest0.java
, which contains the generated unit tests.
Emma is a decent option to collect coverage information form a java program.