@diffblue/cover-client
v0.5.0
Published
Diffblue Cover client library - Node.js API for Diffblue Cover
Downloads
8
Keywords
Readme
Diffblue Cover client library - Node.js API for Diffblue Cover
The Diffblue Cover client library provides a programmatic interface and CLI for communicating with the Diffblue Cover API.
Installation
Using npm:
npm install @diffblue/cover-client
Usage
To use Diffblue Cover to run an analysis and produce test files you will need to provide a JAR file of your compiled code and the path to a directory where you want test files to be written.
In Node.js (using promises):
const Analysis = require('@diffblue/cover-client').Analysis;
const fs = require('fs');
const analysis = new Analysis('https://your-cover-api-domain.com');
const buildFile = fs.createReadStream('./build.jar');
// This is a sample settings object that will not run a useful analysis.
// You can omit the settings parameter when calling `run` to start an analysis with default settings.
const settings = { phases: { firstPhase: { timeout: 10 }}};
const options = { outputTests: './tests' };
analysis.run({ build: buildFile }, settings, options)
.then((results) => {
console.log(`Analysis ended with the status: ${analysis.status}.`);
console.log(`Produced ${results.length} tests in total.`);
console.log(`Test files written to ${options.outputTests}.`);
});
In Typescript (using async/await):
import Analysis from '@diffblue/cover-client';
import { createReadStream } from 'fs';
const analysis = new Analysis('https://your-cover-api-domain.com');
const buildFile = createReadStream('./build.jar');
// This is a sample settings object that will not run a useful analysis.
// You can omit the settings parameter when calling `run` to start an analysis with default settings.
const settings = { phases: { firstPhase: { timeout: 10 }}};
const options = { outputTests: './tests' };
(async () => {
const results = await analysis.run({ build: buildFile }, settings, options);
console.log(`Analysis ended with the status: ${analysis.status}.`);
console.log(`Produced ${results.length} tests in total.`);
console.log(`Test files written to ${options.outputTests}.`);
})();
For more detailed usage, see the programmatic interface documentation.
Full documentation
- Programmatic interface
- Object orientated interface
- Instantiation
- Usage
- Run an analysis (object orientated)
- Start an analysis (object orientated)
- Get analysis status (object orientated)
- Get analysis results (object orientated)
- Cancel an analysis (object orientated)
- Get default analysis settings (object orientated)
- Get API version (object orientated)
- Write test files to disk (object orientated)
- Result pagination
- Lifecycle
- Low level bindings
- Combining results into test classes
- Object orientated interface
- Command line interface
- Tests and checks
- Release procedure
- Utilities
- Code standards
- Contributing guidelines
Copyright 2019 Diffblue Limited. All Rights Reserved.