Convert Figma logo to code with AI

stryker-mutator logostryker-net

Mutation testing for .NET core and .NET framework!

1,761
175
1,761
130

Top Related Projects

PHP Mutation Testing library

1,669

State of the art mutation testing system for the JVM

1,942

Automated code reviews via mutation testing - semantic code coverage.

Quick Overview

Stryker-NET is a mutation testing framework for .NET applications. It introduces faults (mutations) into your code and runs your tests to see if they detect these changes, helping you improve your test suite's quality and coverage.

Pros

  • Supports multiple .NET test frameworks (MSTest, NUnit, xUnit)
  • Integrates with popular CI/CD tools (Azure Pipelines, GitHub Actions)
  • Provides detailed reports and metrics on test effectiveness
  • Actively maintained and regularly updated

Cons

  • Can be resource-intensive and time-consuming for large codebases
  • May produce false positives in certain scenarios
  • Learning curve for interpreting results and optimizing mutation testing
  • Limited support for some advanced .NET features

Code Examples

  1. Basic configuration in stryker-config.json:
{
  "stryker-config": {
    "reporters": [
      "html",
      "progress",
      "dashboard"
    ],
    "project-file": "MyProject.csproj",
    "ignore-methods": ["ToString", "Equals"]
  }
}
  1. Running Stryker-NET via command line:
dotnet stryker
  1. Configuring Stryker-NET in C# code:
using Stryker.Core.Mutators;

var config = new StrykerOptions
{
    Mutators = new[] { Mutator.Arithmetic, Mutator.Boolean },
    ThresholdHigh = 80,
    ThresholdLow = 60
};

Getting Started

  1. Install Stryker-NET as a global tool:

    dotnet tool install -g dotnet-stryker
    
  2. Navigate to your project directory and run:

    dotnet stryker
    
  3. View the generated HTML report in the StrykerOutput folder to analyze mutation testing results.

For more advanced configuration, create a stryker-config.json file in your project root and customize settings as needed.

Competitor Comparisons

PHP Mutation Testing library

Pros of Infection

  • Specifically designed for PHP, offering deep integration with PHP ecosystems
  • Supports a wide range of PHP versions and frameworks
  • Provides detailed reports and metrics for mutation testing results

Cons of Infection

  • Limited to PHP projects only
  • May have a steeper learning curve for developers new to mutation testing
  • Requires additional configuration for complex PHP projects

Code Comparison

Infection (PHP):

<?php
$mutator = new \Infection\Mutator\Arithmetic\Plus();
$mutatedNode = $mutator->mutate($node, $this->getMutationContext());

Stryker.NET (C#):

var mutator = new PlusToMinusMutator();
var mutatedNode = mutator.ApplyMutation(node);

Both Infection and Stryker.NET are powerful mutation testing tools, but they target different programming languages. Infection is tailored for PHP projects, offering deep integration with PHP ecosystems and frameworks. It provides comprehensive reports and supports various PHP versions.

On the other hand, Stryker.NET is designed for .NET projects, offering a broader range of supported languages within the .NET ecosystem. It has a more intuitive setup process and integrates well with popular .NET testing frameworks.

The code comparison shows similar approaches to applying mutations, with each tool using language-specific syntax and structures. Developers should choose the tool that best fits their project's programming language and ecosystem.

1,669

State of the art mutation testing system for the JVM

Pros of PIT

  • Mature and widely adopted in the Java ecosystem
  • Faster execution due to optimized mutation strategies
  • Extensive documentation and community support

Cons of PIT

  • Limited to Java projects only
  • Less flexible configuration options compared to Stryker.NET
  • Steeper learning curve for beginners

Code Comparison

PIT (Java):

@Test
public void testAddition() {
    Calculator calc = new Calculator();
    assertEquals(4, calc.add(2, 2));
}

Stryker.NET (C#):

[Fact]
public void TestAddition()
{
    var calc = new Calculator();
    Assert.Equal(4, calc.Add(2, 2));
}

Both tools use similar approaches for mutation testing, but the syntax differs due to the target languages. PIT focuses on Java-specific optimizations, while Stryker.NET provides a more flexible framework for .NET languages.

PIT excels in performance and has a strong presence in the Java community. However, Stryker.NET offers broader language support within the .NET ecosystem and more customization options.

Choosing between the two depends on the project's technology stack and specific requirements. Java developers may prefer PIT for its maturity and optimization, while .NET developers would benefit from Stryker.NET's flexibility and language support.

1,942

Automated code reviews via mutation testing - semantic code coverage.

Pros of Mutant

  • Supports multiple programming languages (Ruby, JavaScript, etc.)
  • Offers advanced mutation operators for more thorough testing
  • Provides detailed reporting and analytics

Cons of Mutant

  • Steeper learning curve compared to Stryker.NET
  • Less extensive documentation and community support
  • Limited integration with CI/CD pipelines

Code Comparison

Mutant:

Mutant::CLI.run(['--include', 'lib', '--use', 'rspec', '--ignore-subject', 'SomeClass#some_method'])

Stryker.NET:

dotnet stryker --project-file MyProject.csproj --reporters ["html", "progress"]

Key Differences

  • Language Support: Mutant is multi-language, while Stryker.NET focuses on .NET
  • Configuration: Mutant uses command-line options, Stryker.NET supports JSON config
  • Integration: Stryker.NET has better Visual Studio and .NET ecosystem integration

Use Cases

  • Choose Mutant for multi-language projects or advanced mutation testing needs
  • Opt for Stryker.NET in .NET-centric environments or for easier setup and integration

Community and Maintenance

  • Stryker.NET has more frequent updates and a larger contributor base
  • Mutant has a smaller but dedicated community, with less frequent releases

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Nuget Nuget Azure DevOps build Azure DevOps tests Mutation testing badge Slack

tryker.NET

Professor X: For someone who hates mutants... you certainly keep some strange company. William Stryker: Oh, they serve their purpose... as long as they can be controlled.

Introduction

Stryker offers mutation testing for your .NET Core and .NET Framework projects. It allows you to test your tests by temporarily inserting bugs in your source code.

For an introduction to mutation testing and Stryker's features, see stryker-mutator.io. Looking for mutation testing in JavaScript & Typescript or Scala?

Compatibility

Minimum target version:

  • dotnet core 1.1
  • dotnet framework 4.5
  • dotnet standard 1.3

Tested against:

  • dotnet core 3.1
  • dotnet framework 4.8

Getting started

dotnet tool install -g dotnet-stryker
cd /my/unit/test/project/folder
dotnet stryker

For more information read our getting started.

Documentation

For the full documentation on how to use Stryker.NET, see our configuration docs.

Migrating

Coming from a previous version of Stryker.NET? Take a look at our migration guide.

Supported Mutations

For the full list of all available mutations, see the mutations docs.

Supported Reporters

For the full list of all available reporters, see the reporter docs.

Contributing

Want to help develop Stryker.NET? Check out our contribution guide.

Issues for the HTML report should be issued at mutation-testing-elements.