3

I am looking into mutation testing and trying to integrate Stryker into my code base. My application is written in React, Nodejs and currently using Jest for client-side testing and Mocha for server-side testing. I am having a few questions regarding this:

  1. Have anybody tried/looked into mutation testing before? Do you have any thoughts/concerns on this regarding pros and cons?

  2. In terms of Stryker framework, I am curious how Stryker generate mutants? Is there any algorithm used in Stryker to generate mutants?

Any input would be much appreciated. Thank you in advance.

Hannah
  • 31
  • 2

2 Answers2

1

For generic Mutation Testing concepts I totally recomend Pitest (MT implementation for java) docs:

I also wrote on the topic sometime ago: https://pedrorijo.com/blog/intro-mutation/

For your questions, this should give you a good idea of the existing possibilities. Not sure about striker specific details

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
1
  1. Mutation testing is a great tool to improve test "coverage" in a meaningful way. If you want more complete regression coverage in an automated unit test suite, mutation testing can help you find holes in your test coverage, and this can help find and prevent bugs. Be aware though: You still need to think about the types of testing you need. Simply adding tests just to kill off mutants can be damaging. Your tests can end up overly coupled to your implementation this way. However, that doesn't make mutation testing bad, it just means you have to use the tool intelligently, like most tools. Another caveat is that mutation testing can be slow, but as you don't have to run mutation tests as often as the regular test suite, that's not a terrible problem.
  2. Stryker uses specific mutators that look for code that it knows how to mutate. You can find the list of mutators in the handbook. If you are feeling adventurous, you can add your own mutators. But the basic way the algorithm works is:
    1. parse the code into something that can be inspected by the algorithm
    2. look for pieces of code that fit a specific template
    3. modify that code in a way that should still be valid syntax, but changes the behavior in a way that is probably "wrong". (The simplest example is to remove behavior entirely)
Garrett Motzner
  • 3,021
  • 1
  • 13
  • 30