stryker-mutator / stryker-handbook

A comprehensive guide to the stryker ecosystem
Apache License 2.0
71 stars 11 forks source link

Mutator suggestion: modify constants #35

Open Masterxilo opened 4 years ago

Masterxilo commented 4 years ago

There should be a mutator that replaces numeric constants. I imagine the following variants:

this should catch some off-by-one errors.

Example: It would detect that the following function:

export function lessThan100(x: number): boolean {
  if (x < 100) {
    return true;
  }
  return false;
}

Is not appropriately tested by the following testcases:

describe('lessThan100', () => {
  it('should detect which numbers are less than 100', () => {
    expect(lessThan100(100)).toEqual(false);
    expect(lessThan100(98)).toEqual(true);
  });
});