Skip to content

Run mutation tests to ensure the test suite is ok #10

Description

@danicat

Mutation Testing with Selene

To verify the quality of the test suite in this repository, we can use Selene, a mutation testing tool for Go.

1. Install Selene

If you don't have Selene installed, you can install it directly via go install:

go install github.com/danicat/selene@latest

Note: Ensure your $GOPATH/bin is in your system PATH.

2. Prepare the environment

Clone the testquery repository and navigate to its root:

git clone https://github.com/danicat/testquery
cd testquery

3. Run Mutation Testing

Run Selene on the source files. Selene will automatically run the existing tests to generate a coverage profile and will only mutate code that is currently covered by tests.

Run on all core logic files:

selene run *.go

Or run on specific files (e.g., query logic):

selene run query.go

4. Interpreting the Results

Selene will output the status of each mutation:

  • killed: A mutation was introduced, and your tests failed. This is good; it means your tests caught the logic change.
  • survived: A mutation was introduced, but your tests still passed. This indicates a gap in your test suite where a logic change is not being asserted.

The final Score represents the percentage of mutations that your test suite successfully caught.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions