mutesting

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: MIT Imports: 5 Imported by: 0

README

go-mutesting

Go Reference Go package codecov

go-mutesting is a framework for performing mutation testing on Go source code. Its main purpose is to find source code, which is not covered by any tests.

Quick Example

go-mutesting includes a binary which is go-getable.

go get -t -v github.com/leonidboykov/go-mutesting/...

The following command mutates the go-mutesting project with all available mutators.

go-mutesting github.com/leonidboykov/go-mutesting/...

The execution of this command prints for every mutation if it was successfully tested or not. If not, the source code patch is printed out, so the mutation can be investigated. The following shows an example for a patch of a mutation.

for _, d := range opts.Mutator.DisableMutators {
	pattern := strings.HasSuffix(d, "*")

-	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || (!pattern && name == d) {
+	if (pattern && strings.HasPrefix(name, d[:len(d)-2])) || false {
		continue MUTATOR
	}
}

The example shows that the right term (!pattern && name == d) of the || operator is made irrelevant by substituting it with false. Since this change of the source code is not detected by the test suite, meaning the test suite did not fail, we can mark it as untested code.

For the rest of the readme, check out the documentation at https://leonidboykov.github.io/go-mutesting.

Can I make feature requests and report bugs and problems?

Sure, just submit an issue via the project tracker and we will see what I can do.

Slop-free software

This software is 100% human-authored. All AI-generated contributions will be rejected.

slop-free.org logo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MutateWalk

func MutateWalk(pkg *packages.Package, node ast.Node, m mutator.Mutator, skippedLines map[int]struct{}, changeFunc, resetFunc func())

MutateWalk mutates the given node with the given mutator returning a channel to control the mutation steps. It traverses the AST of the given node and calls the method Check of the given mutator to verify that a node can be mutated by the mutator. If a node can be mutated the method Mutate of the given mutator is executed with the node and the control channel. After completion of the traversal the control channel is closed.

func PrintWalk

func PrintWalk(node ast.Node)

PrintWalk traverses the AST of the given node and prints every node to STDOUT.

Types

This section is empty.

Directories

Path Synopsis
cmd
go-mutesting command
sub
internal
diff
Package diff wraps utilities for diff calculation.
Package diff wraps utilities for diff calculation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL