Пример #1
0
        public static int VerifyJsonResults(IEnumerable <string> jsons)
        {
            foreach (var json in jsons)
            {
                var results = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultsFile>(json);

                foreach (var asm in results.Assemblies)
                {
                    using (CIResultOutput.WriteSuite(asm.Name))
                        foreach (var fix in asm.Fixtures)
                        {
                            using (CIResultOutput.WriteSuite(fix.Name))
                                foreach (var test in fix.Tests)
                                {
                                    foreach (var result in test.Results)
                                    {
                                        ConventionMatch.PrintOutResult(result);
                                    }
                                }
                        }
                }
            }


            ConventionMatch.WriteOutTrailer();


            if (ConventionMatch.Invalid.Count > 0)
            {
                return(-1);
            }
            return(0);
        }
Пример #2
0
        public static void PrintOutResult(Result result)
        {
            CIResultOutput.WriteLine("##teamcity[testStarted name='{0}__{1}' captureStandardOutput='true']",
                                     CIResultOutput.Encode(result.Test.Name),
                                     CIResultOutput.Encode(result.Platform));

            CIResultOutput.DontWrite(result.Test.Fixture.Assembly.Name + ".");
            CIResultOutput.DontWrite(result.Test.Fixture.Name + ".");
            Console.Write(result.Test.Name);
            Console.WriteLine("[{0}]", result.Platform);
            Console.Write(result.Kind);
            Console.WriteLine(" ({0})", result.EndTime - result.StartTime);
            Console.WriteLine(result.Output);


            var match = ConventionMatch.ResultMatchesName(result);

            if (!match.HasValue)
            {
                Unknown.Add(result);

                CIResultOutput.WriteLine("##teamcity[testIgnored name='{0}__{1}' message='Result type not specified']",
                                         CIResultOutput.Encode(result.Test.Name),
                                         CIResultOutput.Encode(result.Platform));
                CIResultOutput.PostMatchResult(result, ResultKind.NoError);
                Console.WriteLine("???? Unknown Output ????");
            }
            else if (match.Value)
            {
                Correct.Add(result);
                CIResultOutput.PostMatchResult(result, ResultKind.Success);
                Console.WriteLine("++++ Correct Output ++++");
            }
            else
            {
                Invalid.Add(result);

                CIResultOutput.WriteLine(
                    "##teamcity[testFailed name='{0}_{1}' message='Does not match expected result' details='did not expect {2}']",
                    CIResultOutput.Encode(result.Test.Name), CIResultOutput.Encode(result.Platform), result.Kind);
                CIResultOutput.PostMatchResult(result, ResultKind.Fail);
                Console.WriteLine("!!!! Invalid Output !!!!");
            }
            CIResultOutput.DontWriteLine(String.Empty);
            CIResultOutput.DontWriteLine("*************************");

            CIResultOutput.WriteLine("##teamcity[testFinished name='{0}__{1}' duration='{2}']",
                                     CIResultOutput.Encode(result.Test.Name),
                                     CIResultOutput.Encode(result.Platform),
                                     (result.EndTime - result.StartTime).TotalMilliseconds);
        }
Пример #3
0
        public static void WriteOutTrailer()
        {
            Console.WriteLine();
            Console.WriteLine("*************************");
            Console.WriteLine("*************************");
            Console.WriteLine("*************************");
            Console.WriteLine();

            Console.WriteLine("Correct:{0}, Invalid:{1}, Unknown:{2}", ConventionMatch.Correct.Count, ConventionMatch.Invalid.Count, ConventionMatch.Unknown.Count);
            Console.WriteLine();
            ConventionMatch.ReprintOutItems("Invalid", ConventionMatch.Invalid);
            Console.WriteLine();
            ConventionMatch.ReprintOutItems("Unknown", ConventionMatch.Unknown, true);
        }