https://github.com/sebasg22/nx-mutation
https://github.com/sebasg22/nx-mutation
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/sebasg22/nx-mutation
- Owner: SebasG22
- Created: 2019-08-30T00:50:47.000Z (almost 7 years ago)
- Default Branch: 1.jest
- Last Pushed: 2023-01-07T09:30:24.000Z (over 3 years ago)
- Last Synced: 2025-03-18T06:51:22.671Z (over 1 year ago)
- Language: TypeScript
- Size: 14.1 MB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
# Nx Mutation Testing
It is very common that when a project grows rapidly, it is sought to minimize the amount of errors that can be injected into production code.
### Context
The development team or the rockstar developer always seeks to have a very good result in the coverage of tests but this does not mean that this does not mean that it is 100% free of bugs or that the tests are strong to changes.
To address that, you opt for techniques such as mutation testing which seeks to generate different variations (mutations) of our tests and check how fragile the project changes.
### What is mutation testing ?
Mutation testing is a fault-based testing technique where variations of a software program are subjected to the test dataset. This is done to determine the effectiveness of the test set in isolating the deviations.[1]
### What variations does apply ?
The most common are:
- Arithmetic operator replacement (+,-,/,*,%)
- Logical connector replacement (&&, ||, ===,===)
- Statement removal
- Relational operator replacement (<=, >=)
- Absolute value insertion, etc. ( value)
[See Complete List](https://github.com/stryker-mutator/stryker-handbook/blob/master/mutator-types.md)
If the test survives a variation we say that the generated mutant survived.
## Which tools are available ?
One of the most common tools it's stryker, It support many programming languages:
- Javascript
- .NET
-
Notes:
- Mutation testing does not replace unit tests, rather they prove how resistent they are to changes.
- Mutation testing checks the effectiveness of the unit tests against the different variations, this means that it is based on the unit tests.
This repository contains practical examples of using the Sticker.io tool an an angular builder to mutation testing capabilites to Nx Workspaces.
## Adding mutation testing to your workspace
Nx supports mutation testing as part of their core packages.
You need add to your workspace:
- [Stryker](https://angular.io)
- `ng add @nrwl/stryker`
## Generate an application
Run `ng g @nrwl/angular:app my-app` to generate an application.
## Start using Stryker
There are two ways to use stryker in your project, one is with the `stryker.config.js` or use it over `angular.json`.
### Generating stryker.config.js
Run `ng g stryker my-app` to generate the stryker config for `my-app`.
### Modify angular json
You can modify the `angular.json - mutate` target to pass it the configuration without explicit use `stryker.config.js`
> It accepts most of the same parameters.
## Running mutation tests
Run `ng run my-app:mutate` to start the mutants.
## How to use on CI env ?
Run `ng affected --target=mutate`
## Further help
Visit the [Nx Documentation](https://nx.dev/angular) to learn more.