Пример #1
0
        public void OnAllMutantsTested(IReadOnlyInputComponent reportComponent)
        {
            var jsonReport = JsonReportComponent.FromProjectComponent(reportComponent, _options);

            jsonReport.ThresholdHigh  = _options.ThresholdOptions.ThresholdHigh;
            jsonReport.ThresholdLow   = _options.ThresholdOptions.ThresholdLow;
            jsonReport.ThresholdBreak = _options.ThresholdOptions.ThresholdBreak;

            WriteReportToJsonFile(jsonReport, Path.Combine(_options.BasePath, "StrykerOutput", "reports", "mutation-report.json"));
        }
Пример #2
0
        public void OnAllMutantsTested(IReadOnlyInputComponent reportComponent)
        {
            var jsonReport = JsonReportComponent.FromProjectComponent(reportComponent, _options.ThresholdOptions);

            jsonReport.Name = _options.ProjectUnderTestNameFilter;

            using (var file = File.CreateText(_options.BasePath + "/StrykerLogs/mutation-report.json"))
            {
                file.WriteLine(SerializeJsonReport(jsonReport));
            }
        }
Пример #3
0
        public void JsonReportComponent_ShouldGenerateFileTreeForJsonSerialization()
        {
            var tree         = CSharpSyntaxTree.ParseText("void M(){ int i = 0 + 8; }");
            var originalNode = tree.GetRoot().DescendantNodes().OfType <BinaryExpressionSyntax>().First();

            var mutation = new Mutation()
            {
                OriginalNode    = originalNode,
                ReplacementNode = SyntaxFactory.BinaryExpression(SyntaxKind.SubtractExpression, originalNode.Left, originalNode.Right),
                DisplayName     = "This name should display",
                Type            = MutatorType.Arithmetic
            };

            var folder = new FolderComposite()
            {
                Name = "RootFolder"
            };

            folder.Add(new FileLeaf()
            {
                Name    = "SomeFile.cs",
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        Id           = 55,
                        ResultStatus = MutantStatus.Killed,
                        Mutation     = mutation
                    }
                },
                SourceCode = "void M(){ int i = 0 + 8; }"
            });
            folder.Add(new FileLeaf()
            {
                Name    = "SomeOtherFile.cs",
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        Id           = 56,
                        ResultStatus = MutantStatus.Survived,
                        Mutation     = mutation
                    }
                },
                SourceCode = "void M(){ int i = 0 + 8; }"
            });
            folder.Add(new FileLeaf()
            {
                Name    = "SomeOtherFile.cs",
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        Id           = 56,
                        ResultStatus = MutantStatus.Skipped,
                        Mutation     = mutation
                    }
                },
                SourceCode = "void M(){ int i = 0 + 8; }"
            });

            var result = JsonReportComponent.FromProjectComponent(folder, new ThresholdOptions(80, 60, 0));

            ValidateJsonReportComponent(result, folder, "warning");
            ValidateJsonReportComponent(result.ChildResults.ElementAt(0), folder.Children.ElementAt(0), "ok", 1);
            ValidateJsonReportComponent(result.ChildResults.ElementAt(1), folder.Children.ElementAt(1), "danger", 1);
        }