示例#1
0
        protected void Given_some_mutants_will_survive()
        {
            var baseSlnDir = Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..");

            var survivingMutant = new SurvivingMutant
            {
                SourceFilePath = Path.Combine(baseSlnDir, "someclass.cs"),
                SourceLine     = 123,
                OriginalLine   = "a+b",
                MutatedLine    = "a-b"
            };

            MockMutationTestRunner
            .Setup(r => r.Run(It.IsAny <Config>()))
            .Callback(() =>
            {
                // Raise events that a real MutationTestRunner would raise.
                var classFilePath = Path.Combine(baseSlnDir, "someclass.cs");
                eventListener.BeginMutationOfFile(classFilePath, baseSlnDir, 0, 1);
                eventListener.MemberMutating("System.Void SomeProject.SomeOtherNamespace.SomeClass::SomeMethod(System.Int32)");
                eventListener.SyntaxNodeMutating(0, 1);
                eventListener.MutantSurvived(survivingMutant);
                eventListener.EndMutationOfFile(classFilePath);
            })
            .Returns(Task.FromResult(new MutationTestResult().WithSurvivingMutants(new [] { survivingMutant })));
        }
 public void Then_only_locally_modified_source_files_are_considered_for_mutation()
 {
     MockMutationTestRunner.Verify(r =>
                                   r.Run(It.Is <Config>(c =>
                                                        c.LocallyModifiedSourceFiles.Length == 1 &&
                                                        c.LocallyModifiedSourceFiles.Single() == @"Implementation\PartiallyTestedNumberComparison.cs"
                                                        )));
 }
示例#3
0
        protected void Given_mutation_testing_will_return_errors()
        {
            Given_a_valid_config_file();

            MockMutationTestRunner
            .Setup(r => r.Run(It.IsAny <Config>()))
            .Returns(Task.FromResult(new MutationTestResult().WithError("an example error")));
        }
示例#4
0
 public void Then_the_options_specified_in_the_config_file_are_used()
 {
     MockMutationTestRunner.Verify(x => x.Run(
                                       It.Is <Config>(c =>
                                                      c.SolutionFilePath.EndsWith("../../../../../src/Examples/HasSurvivingMutants/HasSurvivingMutants.sln") &&
                                                      c.TestAssemblyFilePaths.Single().EndsWith($"../../../../../src/Examples/HasSurvivingMutants/Tests/bin/{BuildConfig.AsString}/HasSurvivingMutants.Tests.dll") &&
                                                      c.ProjectFilters.Single() == "HasSurvivingMutants.Implementation" &&
                                                      c.SourceFileFilters.Single() == "Implementation/*.cs" &&
                                                      c.CustomTestRunnerCommand == "src/Examples/HasSurvivingMutants/run-tests.bat arg=123"
                                                      )));
 }
示例#5
0
 public void Then_mutation_testing_is_not_attempted()
 {
     MockMutationTestRunner.Verify(
         mtr => mtr.Run(It.IsAny <Config>()),
         Times.Never);
 }
示例#6
0
 public void Then_mutation_testing_is_not_performed()
 {
     MockMutationTestRunner.Verify(x => x.Run(It.IsAny <Config>()), Times.Never);
 }
示例#7
0
 public void Then_mutation_testing_is_still_performed()
 {
     MockMutationTestRunner.Verify(
         mtr => mtr.Run(It.IsAny <Config>()),
         Times.Once);
 }
示例#8
0
 protected void Given_mutation_testing_will_throw_an_exception(Exception ex)
 {
     MockMutationTestRunner
     .Setup(r => r.Run(It.IsAny <Config>()))
     .Throws(ex);
 }
示例#9
0
 protected void Given_no_mutants_will_survive()
 {
     MockMutationTestRunner
     .Setup(r => r.Run(It.IsAny <Config>()))
     .Returns(Task.FromResult(new MutationTestResult()));
 }
 public void Then_all_source_files_are_considered_for_mutation()
 {
     MockMutationTestRunner.Verify(r =>
                                   r.Run(It.Is <Config>(c => c.LocallyModifiedSourceFiles == null)));
 }