public static void SuiteInitialize(TestContext context)
        {
            if (File.Exists(ResultsFile))
            {
                File.Delete(ResultsFile);
            }

            DotnetTestFixture.Execute("test-results.json");
        }
Exemplo n.º 2
0
        private Task VerifyAssembly(string testAssembly, string args, string comment)
        {
            var settings = new VerifySettings();

            settings.UseDirectory(Path.Combine("Snapshots", "TestLoggerAcceptanceTests", "VerifyTestRunOutput"));
            settings.UseFileName(
                $"{testAssembly}" +
                $"{(args.Length > 0 ? "-" + args : string.Empty)}" +
                $"{(comment.Length > 0 ? "-" + comment : string.Empty)}");

            // Make any paths uniform regardless of OS.
            settings.ScrubLinesWithReplace(x =>
            {
                var options       = RegexOptions.IgnoreCase | RegexOptions.Compiled;
                var prefixedMatch = new Regex(@"^(.{0,}: )(.{0,}test[\/\\]assets[\/\\]Json\.TestLogger)(.{0,})$", options);
                var pathMatch     = new Regex(@"^(.{0,}test[\/\\]assets[\/\\]Json\.TestLogger)(.{0,})$", options);
                if (prefixedMatch.IsMatch(x))
                {
                    var m                  = prefixedMatch.Match(x);
                    var prefix             = m.Groups[1].Captures[0].Value.Replace('\\', '/');
                    var pathForwardSlashes = m.Groups[3].Captures[0].Value.Replace('\\', '/');
                    x = prefix + "test/assets/Json.TestLogger" + pathForwardSlashes;
                }
                else if (pathMatch.IsMatch(x))
                {
                    var m = pathMatch.Match(x);
                    var pathForwardSlashes = m.Groups[2].Captures[0].Value.Replace('\\', '/');
                    x = "test/assets/Json.TestLogger" + pathForwardSlashes;
                }

                return(x);
            });

            DotnetTestFixture.Execute(testAssembly, args, out var resultsFile);
            var testReport = JsonConvert.DeserializeObject <TestReport>(File.ReadAllText(resultsFile));

            return(this.Verify(testReport.TestAssemblies, settings));
        }