Are there really all mutation for conditional statements?

Feb 26, 2015 at 2:12 PM
Hello!

I'm trying to run following simple tests and there should be survived mutants.
[TestFixture]
    public class Class1 {
        [Test]
        public void Foo1() {
            var myClass = new MyClass();
            var sum = myClass.Xcd(1);

            Assert.AreEqual("foo", sum);
        }

        [Test]
        public void Foo12() {
            var myClass = new MyClass();
            var sum = myClass.Xcd(-1);

            Assert.AreEqual("bar", sum);
        }

        [Test, MutationTest]
        public void Boo() {
            MutationTestBuilder<MyClass>
                .For("Xcd")
                .Run();
        }
    }

    public class MyClass {
        public int Sum(int x, int y) {
            return x + y;
        }

        public string Xcd(int i) {
            if (i >= 0) {
                return "foo";
            }
            return "bar";
        }
    }
If I change manually if (i >= 0) to if (i > 0) all tests passes, and I suppose that it should be catched by mutation tests.

I take a look on ConditionalBoundaryTurtle class and it suspiciously small.

Could you please help me?
Feb 27, 2015 at 12:24 PM
Hi.

My guess is that NinjaTurtles can't find your NUnit runner (either it's not in the path, or it isn't in the packages/NUnit.Runner.xxx directory)

This seems to be a reasonably common problem. I'm trying to figure out a way of reporting this in an elegant way before it tries to run the test,and will get that fix into a new version in the not too distant future.

Cheers,
Paul
Mar 3, 2015 at 8:29 AM
Edited Mar 3, 2015 at 8:30 AM
Hello Paul!

Sorry for the late response. But I've checked typical issues before create this post. I'm able to run tests and I install all necessary libraries. I even download and compile NinjaTurtles project, run all tests and everything works =)

But when I try to create some cases that could demonstrate power of mutation testing I failed to get expected result from mutants. To be honest, I'd like to share knowledge about mutation testing to my colleagues, but without simple and working examples it will be hard ;)

To be very clear, I'd like to explain what I try to do and what I expect, so you may correct me if there is misunderstanding.
  • I create some very simple code with condition "more or equal".
  • I create two tests that test "less" and "more" cases. Tests should pass.
  • At this point I may think that job is done, but.... and I do mutational testing!
  • I create mutational testing with method from the first step. Run it.
  • I can see several mutants and one or more of them should survive. Because when "more or equal" changes to "more" and all tests for the particular functions are green - that means I'm in trouble. Tests won't warn me when condition in statement accidentally changes.
Do I get it right?

Finally I once again check stuff and read latest questions and findout that I have same issue that described here https://ninjaturtles.codeplex.com/discussions/574629
Tests doesn't work with R# TestRunner.

Could you please check it once again or where in source code could I find it to communicate with JetBrains and R# team? I know some guys from R# personally.
Mar 3, 2015 at 5:58 PM
Hi Violet. Would you be able to put together a sample solution for me that isn't working for you, and email it to me at pms1969 [at] gmail.com please? I'll have a look and see if I can't fix your issue for you. I have resharper, so I won't be just having a poke around in the dark.

Cheers,
Paul