Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JS Fest 2018. Андрей Кучеренко. Мутационное тестирование в JavaScript

63 views

Published on

Мутационное тестирование – один из инструментов для повышение качества юнит тестов и, как следствие, всего продукта. В данном докладе будут описаны принципы, по которым работает мутационное тестирование, и инструменты, которые используются для проектов, написанных на JavaScript и TypeScript

Published in: Education
  • Be the first to comment

  • Be the first to like this

JS Fest 2018. Андрей Кучеренко. Мутационное тестирование в JavaScript

  1. 1. Mutation Testing inMutation Testing in JavaScriptJavaScript
  2. 2. Andrey KucherenkoAndrey Kucherenko
  3. 3. Mutation�testing�(or�mutation� analysis�or�program�mutation)�is� used�to�design�new�software�tests� and�evaluate�the�quality�of�existing� software�tests.�Mutation�testing� involves�modifying�a�program�in� small�ways. �Each�mutated�version� is�called�a�mutant�and�tests�detect� and�reject�mutants�by�causing�the� behavior�of�the�original�version�to� differ�from�the�mutant.�This�is� called�killingthe�mutant.�Test� suites�are�measured�by�the� percentage�of�mutants�that�they� kill.�New�tests�can�be�designed�to� kill�additional�mutants.�Mutants�are� based�on�well�defined�mutation� operators�that�either�mimic�typical� programming�errors�(such�as�using� the�wrong�operator�or�variable�name)� or�force�the�creation�of�valuable� tests�(such�as�dividing�each� expression�by�zero).�The�purpose�is� to�help�the�tester�develop�effective� tests�or�locate�weaknesses�in�the� [1]
  4. 4. Language Framework Java PiTest Ruby Mutant PHP Humburg/Infection PHP C# VisualMutator Python Cosmic Ray/ MutPy LLVM Mull
  5. 5. and TypeScript
  6. 6. npm install -g stryker-cli
  7. 7. stryker init
  8. 8. stryker run
  9. 9. export class CountService { sum(a, b) { return a + b; } divide(a, b) { return a / b; } modulo(a, b) { return a % b; } } describe('Count Service', () => { let sut; beforeEach(() => { sut = new CountService(); }) it('should sum numbers', () => { expect(sut.sum(2, 2)).toEqual(4); }); it('should get divided numbers', () => { expect(sut.divide(2, 1)).toEqual(2); }) });
  10. 10. mutantsmutants
  11. 11. LimitationsLimitations Performance Not all test frameworks supported Not all build tools supported Not all envs supported Not all cases mutated
  12. 12. Questions?

×