Dev Thoughts

Musings from my development journey.

Topics

How to Write Better Code Using Mutation Testing

large

Talk by John Backus at Rails Conf 2017.

Mutation Coverage

"The idea is that if code can be changed and your tests do not notice, then either that code isn't being covered or it does not have a speced side effect." - mbj

mutant gem automatically checks for mutation coverage in order to improve the test suite.

Implementation can help to assist with crafting more strict interfaces for a program. Examples can be: forcing type casting, raising errors instead of failing silently, and structuring dates.

Other use cases are for hardening Regular Expressions to catch pattern matching edge cases.

Additionally, mutation coverage can help with cleaning up API service calls.

Legacy Code Refactoring

  • Can help finding an original dev's intent
  • Can reveal how the component is being used currently
  • Supplies a checklist prior to modifying legacy code

Mutation testing also assists with detecting dead code.

Benefits

  • Learning faster
  • Shipping with fewer bugs
  • Fewer regression issues
  • Writing simpler code
6205288ecbfff3df3e44008f296d7d76
Eskeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeetit
Comment posted by Ducko over 1 year ago
6f560065e46f26926e606868731ea15c
asdddssssssssssssssaaaaaaaaaaaaaaa
Comment posted by Soner about 1 year ago
6f560065e46f26926e606868731ea15c
ben bsoodsadsa sjiadjasi
Comment posted by Soner about 1 year ago
6f560065e46f26926e606868731ea15c
dssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
Comment posted by Soner about 1 year ago
6f560065e46f26926e606868731ea15c
xcsdads sdsadsa dsadsadasdsads sadsadsdas sdadsasdassda sadasdadsa
Comment posted by Soner about 1 year ago
7a1bbb84db3e763b15cf8295265636a7
123123123
Comment posted by Juan 11 months ago
7a1bbb84db3e763b15cf8295265636a7
12312312312312312312312312312312312312312222222222222222222222222222222222222222222222222222222222222222222222222222222
Comment posted by Juan 11 months ago