Skip to content

Commit

Permalink
feat(stryker config): rename config setting reporter to reporters (
Browse files Browse the repository at this point in the history
…#1088)

Deprecates the `reporter` property. Reporters should be set using the `reporters` property and they should be an array (instead of an array or string).

Fixes #793
  • Loading branch information
simondel committed Aug 19, 2018
1 parent 5690760 commit 584218a
Show file tree
Hide file tree
Showing 39 changed files with 131 additions and 92 deletions.
Binary file modified .travis/Stryker.db
Binary file not shown.
2 changes: 1 addition & 1 deletion integrationTest/test/angular-project/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (config) {
browsers: ['ChromeHeadless']
}
},
reporter: ['event-recorder'],
reporters: ['event-recorder'],
coverageAnalysis: 'off',
maxConcurrentTestRunners: 1
});
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/babel-transpiling/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (config) {
'babel'
],
babelrcFile: '.babelrc',
reporter: ['clear-text', 'html', 'event-recorder'],
reporters: ['clear-text', 'html', 'event-recorder'],
maxConcurrentTestRunners: 2,
logLevel: 'info'
});
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/jasmine-jasmine/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (config) {
coverageAnalysis: 'perTest',
testFramework: 'jasmine',
testRunner: 'jasmine',
reporter: ['clear-text', 'event-recorder'],
reporters: ['clear-text', 'event-recorder'],
maxConcurrentTestRunners: 1,
jasmineConfigFile: 'spec/support/jasmine.json',
fileLogLevel: LogLevel.Debug
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/jest-react/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function(config) {
testRunner: "jest",
mutator: "javascript",
transpilers: [],
reporter: ["event-recorder"],
reporters: ["event-recorder"],
coverageAnalysis: "off",
mutate: ["src/**/*.js", "!src/**/*.test.js"],
maxConcurrentTestRunners: 1,
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/karma-jasmine/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function (config) {
mutate: ['src/*.js'],
testFramework: 'jasmine',
testRunner: 'karma',
reporter: ['clear-text', 'html'],
reporters: ['clear-text', 'html'],
maxConcurrentTestRunners: 2,
port: 9254,
karmaConfig: {
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/karma-mocha/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function (config) {
mutator: 'javascript',
testFramework: 'mocha',
testRunner: 'karma',
reporter: ['clear-text', 'html'],
reporters: ['clear-text', 'html'],
karmaConfig: {
frameworks: ['mocha', 'chai'],
files: ['src/*.js', 'test/*.js']
Expand Down
2 changes: 1 addition & 1 deletion integrationTest/test/mocha-mocha/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function (config) {
mutate: ['src/*.js'],
testFramework: 'mocha',
testRunner: 'mocha',
reporter: ['clear-text', 'html', 'event-recorder'],
reporters: ['clear-text', 'html', 'event-recorder'],
maxConcurrentTestRunners: 2,
port: 9264,
mochaOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function (config) {
testFramework: 'mocha',
testRunner: 'mocha',
coverageAnalysis: 'off',
reporter: ['clear-text', 'html', 'event-recorder'],
reporters: ['clear-text', 'html', 'event-recorder'],
maxConcurrentTestRunners: 2,
mutator: 'typescript',
logLevel: 'info',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (config) {
],
testFramework: 'jasmine',
testRunner: 'karma',
reporter: ['clear-text', 'html'],
reporters: ['clear-text', 'html'],
maxConcurrentTestRunners: 2,
port: 9274,
karmaConfig: {
Expand Down
5 changes: 3 additions & 2 deletions packages/stryker-api/src/config/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogLevel, StrykerOptions, MutatorDescriptor, MutationScoreThresholds } from '../../core';
import { LogLevel, MutationScoreThresholds, MutatorDescriptor, StrykerOptions } from '../../core';

export default class Config implements StrykerOptions {

Expand All @@ -13,7 +13,8 @@ export default class Config implements StrykerOptions {
timeoutFactor = 1.5;
plugins: string[] = ['stryker-*'];
port = 9234;
reporter = ['progress', 'clear-text'];
reporter = [];
reporters: string[] = ['progress', 'clear-text'];
coverageAnalysis: 'perTest' | 'all' | 'off' = 'perTest';
testRunner: string = 'command';
testFramework: string;
Expand Down
12 changes: 8 additions & 4 deletions packages/stryker-api/src/core/StrykerOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LogLevel from './LogLevel';
import MutationScoreThresholds from './MutationScoreThresholds';
import MutatorDescriptor from './MutatorDescriptor';
import LogLevel from './LogLevel';

interface StrykerOptions {
// this ensures that plugins can load custom config.
Expand Down Expand Up @@ -98,11 +98,15 @@ interface StrykerOptions {
coverageAnalysis?: 'perTest' | 'all' | 'off';

/**
* The name (or names) of the reporter to use
* Possible values: 'clear-text', 'progress'.
* Load more plugins to be able to use more plugins
* DEPRECATED PROPERTY. Please use the `reporters` property
*/
reporter?: string | string[];
/**
* The names of the reporters to use
* Possible values: 'clear-text', 'progress'.
* Load more plugins to be able to use more reporters
*/
reporters?: string[];

/**
* The log level for logging to a file. If defined, stryker will output a log file called "stryker.log".
Expand Down
1 change: 1 addition & 0 deletions packages/stryker-api/testResources/module/useCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const optionsAllArgs: StrykerOptions = {
testFramework: 'string',
testRunner: 'string',
reporter: 'string',
repoters: ['reporter'],
logLevel: LogLevel.Fatal,
timeoutMs: 1,
timeoutFactor: 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-babel-transpiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"peerDependencies": {
"babel-core": "^6.26.0",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"initStrykerConfig": {
"babelrcFile": ".babelrc",
Expand Down
4 changes: 2 additions & 2 deletions packages/stryker-html-reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ If you do descide to choose specific modules, don't forget to add `'stryker-html

### Use the reporter

In order to use the reporter, you must add `'html'` as single reporter or add it to the list. For example: `reporter: 'html'` or `reporter: ['html', 'progress']`.
In order to use the reporter, you must add `'html'` to the reporters. For example: `reporters: ['html', 'progress']`.

### Options

Expand All @@ -51,7 +51,7 @@ Configure the base directory to write the html report to.
exports = function(config){
config.set({
// ...
reporter: 'html', // or ['html', 'progress'] to configure multiple reporters at once
reporters: ['html'], // You may also want to specify other reporters
htmlReporter: {
baseDir: 'reports/mutation/html' // this is the default
},
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-html-reporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"typed-html": "~0.6.0"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"devDependencies": {
"@types/file-url": "~2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-jasmine-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-jasmine-runner#readme",
"peerDependencies": {
"jasmine": ">=2",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"devDependencies": {
"stryker-api": "^0.19.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-jasmine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-jasmine#readme",
"peerDependencies": {
"jasmine-core": ">=2",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"devDependencies": {
"stryker-api": "^0.19.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-javascript-mutator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"stryker-mutator-specification": "^0.4.0"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"initStrykerConfig": {
"mutate": [
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-jest-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"peerDependencies": {
"jest": ">= 22.0.0",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"dependencies": {
"semver": "~5.5.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-jest-runner/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(config) {
testFramework: 'mocha',
mutator: 'typescript',
transpilers: ['typescript'],
reporter: ['clear-text', 'progress', 'html', 'dashboard'],
reporters: ['clear-text', 'progress', 'html', 'dashboard'],
tsconfigFile: 'tsconfig.json',
coverageAnalysis: 'perTest',
logLevel: 'info'
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-karma-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-karma-runner#readme",
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
},
"devDependencies": {
"@types/express": "~4.16.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-mocha-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
},
"peerDependencies": {
"mocha": ">= 2.3.3 < 6",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
}
}
2 changes: 1 addition & 1 deletion packages/stryker-mocha-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
},
"peerDependencies": {
"mocha": ">= 2.3.3 < 6",
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
}
}
2 changes: 1 addition & 1 deletion packages/stryker-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"surrial": "~0.1.3"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0",
"stryker-api": ">=0.18.0 <0.21.0",
"typescript": "^2.4.2"
},
"initStrykerConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-vue-mutator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"vue-template-compiler": "^2.0.0"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0",
"stryker-api": ">=0.18.0 <0.21.0",
"vue-template-compiler": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/stryker-webpack-transpiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"webpack": "~4.16.0"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0",
"stryker-api": ">=0.18.0 <0.21.0",
"webpack": ">=2.0.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker-webpack-transpiler/stryker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function (config) {
testFramework: "mocha",
mutator: "typescript",
transpilers: ["typescript"],
reporter: ["clear-text", "progress", "html"],
reporters: ["clear-text", "progress", "html"],
tsconfigFile: "tsconfig.json",
coverageAnalysis: "off",
logLevel: "info",
Expand Down
10 changes: 5 additions & 5 deletions packages/stryker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = function(config){
],
testFramework: 'mocha',
testRunner: 'mocha',
reporter: ['progress', 'clear-text', 'dots', 'html', 'event-recorder'],
reporters: ['progress', 'clear-text', 'dots', 'html', 'event-recorder'],
coverageAnalysis: 'perTest'
});
}
Expand Down Expand Up @@ -176,14 +176,14 @@ When using the config file, you can provide either a string representing the mut
With `transpilers` you configure which transpiler plugins should transpile the code before it's executed. This is an array where the transpilers are called in the other of the array. This defaults to an empty array meaning no transpilation will be done.

#### Reporters
**Command line:** `--reporter clear-text,progress,dots,dashboard`
**Config file:** `reporter: ['clear-text', 'progress', 'dots', 'dashboard']`
**Command line:** `--reporters clear-text,progress,dots,dashboard`
**Config file:** `reporters: ['clear-text', 'progress', 'dots', 'dashboard']`
**Default value:** `['clear-text', 'progress']`
**Mandatory**: no
**Description:**
With `reporter` you can set a reporter or group of reporters for stryker to use.
With `reporters` you can set the reporters for stryker to use.
These reporters can be used out of the box: `clear-text`, `progress`, `dots`, `dashboard` and `event-recorder`.
By default `clear-text` and `progress` are active if no reporter is configured.
By default `clear-text` and `progress` are active if no reporters are configured.
You can load additional plugins to get more reporters. See [stryker-mutator.io](https://stryker-mutator.io)
for an up-to-date list of supported reporter plugins and a description on each reporter.

Expand Down
2 changes: 1 addition & 1 deletion packages/stryker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@
"stryker-api": "^0.19.0"
},
"peerDependencies": {
"stryker-api": ">=0.18.0 <0.20.0"
"stryker-api": ">=0.18.0 <0.21.0"
}
}
18 changes: 7 additions & 11 deletions packages/stryker/src/ReporterOrchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { StrykerOptions } from 'stryker-api/core';
import { getLogger } from 'stryker-api/logging';
import { ReporterFactory } from 'stryker-api/report';
import BroadcastReporter, { NamedReporter } from './reporters/BroadcastReporter';
import ClearTextReporter from './reporters/ClearTextReporter';
import ProgressReporter from './reporters/ProgressReporter';
import ProgressAppendOnlyReporter from './reporters/ProgressAppendOnlyReporter';
import DashboardReporter from './reporters/DashboardReporter';
import DotsReporter from './reporters/DotsReporter';
import EventRecorderReporter from './reporters/EventRecorderReporter';
import BroadcastReporter, { NamedReporter } from './reporters/BroadcastReporter';
import DashboardReporter from './reporters/DashboardReporter';
import ProgressAppendOnlyReporter from './reporters/ProgressAppendOnlyReporter';
import ProgressReporter from './reporters/ProgressReporter';
import StrictReporter from './reporters/StrictReporter';
import { getLogger } from 'stryker-api/logging';

function registerDefaultReporters() {
ReporterFactory.instance().register('progress-append-only', ProgressAppendOnlyReporter);
Expand All @@ -28,15 +28,11 @@ export default class ReporterOrchestrator {

public createBroadcastReporter(): StrictReporter {
let reporters: NamedReporter[] = [];
let reporterOption = this.options.reporter;
const reporterOption = this.options.reporters;
if (reporterOption) {
if (Array.isArray(reporterOption)) {
reporterOption.forEach(reporterName => reporters.push(this.createReporter(reporterName)));
} else {
reporters.push(this.createReporter(reporterOption));
}
} else {
this.log.warn(`No reporter configured. Please configure one or more reporters in the (for example: reporter: 'progress')`);
this.log.warn(`No reporter configured. Please configure one or more reporters in the (for example: reporters: ['progress'])`);
this.logPossibleReporters();
}
return new BroadcastReporter(reporters);
Expand Down
2 changes: 1 addition & 1 deletion packages/stryker/src/StrykerCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class StrykerCli {
.option('--testRunner <name>', `The name of the test runner you want to use`)
.option('--mutator <name>', `The name of the mutant generator you want to use`)
.option('--transpilers <listOfTranspilers>', 'A comma separated list of transpilers to use.', this.list)
.option('--reporter <name>', 'A comma separated list of the names of the reporter(s) you want to use', this.list)
.option('--reporters <name>', 'A comma separated list of the names of the reporter(s) you want to use', this.list)
.option('--plugins <listOfPlugins>', 'A list of plugins you want stryker to load (`require`).', this.list)
.option('--port <n>', 'A free port for the test runner to use (if it needs to). Any additional test runners will be spawned using n+1, n+2, etc', parseInt)
.option('--timeoutMs <number>', 'Tweak the absolute timeout used to wait for a test runner to complete', parseInt)
Expand Down
16 changes: 13 additions & 3 deletions packages/stryker/src/config/ConfigReader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as _ from 'lodash';
import * as fs from 'mz/fs';
import * as path from 'path';
import { Config } from 'stryker-api/config';
import { StrykerOptions } from 'stryker-api/core';
import * as fs from 'mz/fs';
import { getLogger } from 'stryker-api/logging';
import * as path from 'path';
import * as _ from 'lodash';
import StrykerError from '../utils/StrykerError';

export const CONFIG_SYNTAX_HELP = ' module.exports = function(config) {\n' +
Expand Down Expand Up @@ -31,6 +31,16 @@ export default class ConfigReader {

// merge the config from config file and cliOptions (precedence)
config.set(this.cliOptions);

if (config.reporter.length) {
if (Array.isArray(config.reporter)) {
config.reporters = config.reporter;
} else {
config.reporters = [config.reporter];
}
this.log.warn(`DEPRECATED: please change the config setting 'reporter: ${JSON.stringify(config.reporter)}' into 'reporters: ${JSON.stringify(config.reporters)}'`);
}

return config;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/stryker/src/config/ConfigValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class ConfigValidator {
this.validateIsNumber('port', this.strykerConfig.port);
this.validateIsNumber('maxConcurrentTestRunners', this.strykerConfig.maxConcurrentTestRunners);
this.validateIsStringArray('plugins', this.strykerConfig.plugins);
this.validateIsStringArray('reporter', this.strykerConfig.reporter);
this.validateIsStringArray('reporters', this.strykerConfig.reporters);
this.validateIsStringArray('transpilers', this.strykerConfig.transpilers);
this.validateCoverageAnalysis();
this.validateCoverageAnalysisWithRespectToTranspilers();
Expand Down
Loading

0 comments on commit 584218a

Please sign in to comment.