This project is read-only.

Getting started: writing mutation tests for a method

You create a mutation test for a method just as you would create any other test for it. You might want to consider categorising the test as well. Also, make sure you add the NinjaTurtles.MutationTestAttribute to it as well. This prevents your mutation tests being run by other mutation tests (and so ad infinitum...).

Example:
        [Test, Category("Mutation"), MutationTest]
        public void Add_MutationTests()
        {
        }
Use the MutationTestBuilder to create a mutation test for a method. A fluent interface is provided.

Example:
        [Test, Category("Mutation"), MutationTest]
        public void Add_MutationTests()
        {
            MutationTestBuilder<SimpleCalculator>
                .For("Add")
                .Run();
        }
You can test non-exposed classes and methods. If your class is not public, you just use a non-generic MutationTestBuilder:
        [Test, Category("Mutation"), MutationTest]
        public void Add_MutationTests()
        {
            MutationTestBuilder
                .For("SomePrivateClass", "SomeMethod")
                .Run();
        }
And if your method is overloaded, you can identify the overload in the same way the .NET framework does, by specifying the types of the parameters that it takes:
        [Test, Category("Mutation"), MutationTest]
        public void Add_MutationTests()
        {
            MutationTestBuilder<SimpleCalculator>
                .For("Add", new[] { typeof(long), typeof(long) })
                .Run();
        }

Last edited Jun 28, 2012 at 1:57 PM by davidmus, version 2

Comments

No comments yet.