Skip to content

Commit

Permalink
Add docs for stryker logger (mutation badge, cloud HTML report)
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed Dec 28, 2021
1 parent b6e469e commit 3e765d0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/guide/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ After Infection completes its job, the `mutation-report.html` file will be gener

Takes precedence over `logger.html` setting inside `infection.json` file. If you want to always generate HTML report, it's better to configure it inside `infection.json`, see [here](/guide/usage.html).

> If you want to store HTML report in the cloud (useful for OSS projects), see [Stryker Dashboard](/guide/mutation-badge.html) integration
### `--skip-initial-tests`

If you have already run the test suite to ensure it is passing, and you are providing coverage using `--coverage` then you can use this option to increase performance by not running the entire test suite again.
Expand Down
44 changes: 29 additions & 15 deletions src/guide/mutation-badge.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
---
title: Mutation Badge
title: Mutation Badge, cloud HTML report
type: guide
order: 8
---

It's possible to add a fancy mutation score badge for your project.
We use the [Stryker Dashboard](https://dashboard.stryker-mutator.io/) to store mutation score for badges and host HTML reports in the cloud. [Stryker](https://stryker-mutator.io) is a mutation testing framework for Javascript that shares its service for other mutations frameworks.

## How to set it up

[![Infection MSI](https://badge.stryker-mutator.io/github.com/infection/infection/master)](https://infection.github.io)

Take these steps to enable the mutation score badge on your repository:
Take these steps to enable the mutation score badge / cloud HTML report on your repository:

1. Make sure you have enabled a continuous integration service for your project.

We use [`ondram/ci-detector`](https://github.com/OndraM/ci-detector) to detect continuous-integration services.

Feel free to request an additional integration there if the list of [currently supported continuous-integration servers](https://github.com/OndraM/ci-detector#supported-continuous-integration-servers) does not contain a service you require.

2. Go to https://dashboard.stryker-mutator.io and sign in with your GitHub account.
2. Go to https://dashboard.stryker-mutator.io and sign in with your GitHub account.

We use the [Stryker Dashboard](https://dashboard.stryker-mutator.io/) to store mutation score for badges. Stryker is a mutation testing framework for Javascript that shares its service for other mutations frameworks.
3. Enable a repository for which you want to create a mutation badge / cloud HTML report. Stryker Dashboard will generate a key for you automatically.

3. Enable a repository for which you want to create a mutation badge. Stryker Dashboard will generate a key for you automatically.
4. Provide the API key for your project as a secret environment variable - either `INFECTION_DASHBOARD_API_KEY` or `STRYKER_DASHBOARD_API_KEY` can be used.

4. Provide the API key for your project as a secret environment variable - either `INFECTION_BADGE_API_KEY` or `STRYKER_DASHBOARD_API_KEY` can be used.
5. Configure the `stryker` logger in your `infection.json` file:

5. Configure the badge logger in your `infection.json` file (you will need Infection version `0.9.0` or higher):
for badge

```json
{
"logs": {
"badge": {
"branch": "/^release-.*$/"
"stryker": {
"badge": "/^release-.*$/"
}
}
}
```

or for HTML report to host it on Stryker Dashboard

```json
{
"logs": {
"stryker": {
"report": "/^release-.*$/"
}
}
}
Expand All @@ -43,21 +55,23 @@ Take these steps to enable the mutation score badge on your repository:
```json
{
"logs": {
"badge": {
"branch": "main"
"stryker": {
"badge": "main"
}
}
}
```

6. Force a build by running:
7. Force a build by running:

```shell
$ git push origin master
```

Your badge will be available at: `https://badge.stryker-mutator.io/github.com/{username}/{repository_name}/{branch}`. (don't forget to add it to your readme file)
HTML report will be available at URL: `https://badge.stryker-mutator.io/github.com/{username}/{repository_name}/{branch}`.

For example https://dashboard.stryker-mutator.io/reports/github.com/infection/infection/master

If you want to make mutation badge as a link to Infection, use `[![Infection MSI](https://badge.stryker-mutator.io/github.com/{username}/{repository_name}/{branch})](https://infection.github.io)`
To get the Badge image, go to Stryker Dashboard and copy the link there. Don't forget to add it to your readme file.

That's it! Hope you like it.
2 changes: 1 addition & 1 deletion src/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ You can commit it to the VCS and, if necessary, override it locally by creating
* `timeout` - the maximum allowed time for mutated processes to run, in whole seconds, before they are considered a timeout. Make sure to set it to higher value than your tests are executed in seconds to avoid false-positives.
* `logs`
* `text` - human-readable text log file. Must see to understand what is going on during mutation process.
* `html` - human-readable report, similar to PHPUnit HTML report. Based on [Stryker Elements](https://stryker-mutator.io/blog/one-mutation-testing-html-report/). See [an example](/static/html-report-example.html).
* `html` - human-readable report, similar to PHPUnit HTML report. Based on [Stryker Elements](https://stryker-mutator.io/blog/one-mutation-testing-html-report/). Here is [an example](/static/html-report-example.html) for Infection itself. If you want to store HTML report in the cloud (useful for OSS projects), see [Stryker Dashboard](/guide/mutation-badge.html) integration.
* `summary` - summary log file, which will only display the amount of mutants per category, (Killed, Errored, Escaped, Timed Out, Skipped, and Not Covered)
* `json` - machine-readable file in JSON format. Can be programmatically analyzed. In addition to general stats, contains original, mutated code, diff and test framework output for each Mutant.
* `perMutator` - a markdown file which will give a break-down of the effectiveness of each mutator.
Expand Down

0 comments on commit 3e765d0

Please sign in to comment.