示例#1
0
        public static void GetNunitRegressionInfo(string curXml, string preXml, out int PositiveRegression, out int NegativeRegression, out int newTestCase)
        {
            PositiveRegression = 0;
            NegativeRegression = 0;
            newTestCase        = 0;
            Console.WriteLine("nunit regression info started");
            if (preXml == null || curXml == null || !File.Exists(preXml) || !File.Exists(curXml))
            {
                return;
            }
            try
            {
                NuintTestResult preTestResult = new NuintTestResult(0, preXml);
                NuintTestResult curTestResult = new NuintTestResult(0, curXml);

                int ix1 = 0;
                int ix2 = 0;
                while (ix1 < preTestResult.results.Count && ix2 < curTestResult.results.Count)
                {
                    int flag = string.Compare(preTestResult.results[ix1].Name, curTestResult.results[ix2].Name);
                    if (flag == 0)
                    {
                        if (preTestResult.results[ix1].Result == NuintTestCaseResult.ResultType.SUCCESS &&
                            (curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.ERROR ||
                             curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.FAILURE))
                        {
                            ++PositiveRegression;
                        }
                        else if ((preTestResult.results[ix1].Result == NuintTestCaseResult.ResultType.FAILURE ||
                                  curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.ERROR) &&
                                 curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.SUCCESS)
                        {
                            --NegativeRegression;
                        }

                        ++ix1;
                        ++ix2;
                    }
                    if (flag > 0)
                    {
                        ++ix2;
                    }
                    else
                    {
                        ++ix1;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                PositiveRegression = 0;
                NegativeRegression = 0;
            }
            Console.WriteLine("nunit regression info done");
        }
示例#2
0
        /// <summary>
        /// this function is to do the comparison
        /// </summary>
        /// <param name="result1">result1 is from previous xml </param>
        /// <param name="result2">result2 is from current xml </param>
        /// <returns></returns>
        public static List <NunitDiffResult> NuintDiff(NuintTestResult result1, NuintTestResult result2)
        {
            if (result1 == null || result2 == null)
            {
                throw new ArgumentNullException("some arguments are null");
            }

            List <NunitDiffResult> diff = new List <NunitDiffResult>();
            int ix1 = 0;
            int ix2 = 0;

            while (ix1 < result1.results.Count() && ix2 < result2.results.Count())
            {
                if (result1.results[ix1].Name == result2.results[ix2].Name)
                {
                    if (result1.results[ix1].Executed != result2.results[ix2].Executed || result1.results[ix1].Result != result2.results[ix2].Result)
                    {
                        diff.Add(new NunitDiffResult(result1.results[ix1], result2.results[ix2]));
                    }
                    ++ix1;
                    ++ix2;
                }
                else
                {
                    if (string.Compare(result1.results[ix1].Name, result2.results[ix2].Name) > 0)
                    {
                        diff.Add(new NunitDiffResult(null, result2.results[ix2]));
                        ++ix2;
                    }
                    else
                    {
                        diff.Add(new NunitDiffResult(result1.results[ix1], null));
                        ++ix1;
                    }
                }
            }

            if (ix1 != result1.results.Count())
            {
                for (; ix1 < result1.results.Count(); ++ix1)
                {
                    diff.Add(new NunitDiffResult(result1.results[ix1], null));
                }
            }
            else
            {
                for (; ix2 < result2.results.Count(); ++ix2)
                {
                    diff.Add(new NunitDiffResult(null, result2.results[ix2]));
                }
            }

            return(diff);
        }
示例#3
0
        public static void GetNunitRegressionInfo(string curXml, string preXml, out int PositiveRegression, out int NegativeRegression, out int newTestCase)
        {
            PositiveRegression = 0;
            NegativeRegression = 0;
            newTestCase = 0;
            Console.WriteLine("nunit regression info started");
            if (preXml == null || curXml == null || !File.Exists(preXml) || !File.Exists(curXml))
                return;
            try
            {
                NuintTestResult preTestResult = new NuintTestResult(0, preXml);
                NuintTestResult curTestResult = new NuintTestResult(0, curXml);

                int ix1 = 0;
                int ix2 = 0;
                while (ix1 < preTestResult.results.Count && ix2 < curTestResult.results.Count)
                {
                    int flag = string.Compare(preTestResult.results[ix1].Name, curTestResult.results[ix2].Name);
                    if (flag == 0)
                    {
                        if (preTestResult.results[ix1].Result == NuintTestCaseResult.ResultType.SUCCESS &&
                            (curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.ERROR ||
                            curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.FAILURE))
                            ++PositiveRegression;
                        else if ((preTestResult.results[ix1].Result == NuintTestCaseResult.ResultType.FAILURE ||
                            curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.ERROR) &&
                            curTestResult.results[ix2].Result == NuintTestCaseResult.ResultType.SUCCESS)
                            --NegativeRegression;

                        ++ix1;
                        ++ix2;
                    }
                    if (flag > 0)
                    {
                        ++ix2;
                    }
                    else
                    {
                        ++ix1;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                PositiveRegression = 0;
                NegativeRegression = 0;
            }
            Console.WriteLine("nunit regression info done");
        }
示例#4
0
        /// <summary>
        /// this function is to append the difference between xml files to the report
        /// </summary>
        /// <param name="curPath"></param>
        /// <param name="prePath"></param>
        /// <param name="body"></param>
        public static void AppendNuintDiff(string curPath, string prePath, ref StringBuilder body)
        {
            int successToFailure = 0, failureToSuccess = 0;

            if (body == null)
            {
                body = new StringBuilder();
            }
            if (prePath == null || curPath == null)
            {
                return;
            }

            NuintTestResult pre = new NuintTestResult(0, prePath);
            NuintTestResult cur = new NuintTestResult(0, curPath);

            if (pre.results == null || cur.results == null)
            {
                return;
            }
            else if (pre.results.Count == 0 || cur.results.Count == 0)
            {
                return;
            }

            List <NunitDiffResult> diff = NuintDiff(pre, cur);

            Console.WriteLine(diff.Count);
            if (diff.Count == 0)
            {
                Console.WriteLine("No Change in tests");
                body.AppendLine("<h4>" + "No Change in tests" + "<h4>");

                return;
            }
            Console.WriteLine("starting creation of report");
            foreach (NunitDiffResult result in diff)
            {
                if (result.result1 != null && result.result2 != null)
                {
                    if (result.result1.Result == NuintTestCaseResult.ResultType.SUCCESS && (result.result2.Result == NuintTestCaseResult.ResultType.FAILURE || result.result2.Result == NuintTestCaseResult.ResultType.ERROR))
                    {
                        successToFailure++;
                    }
                    if ((result.result1.Result == NuintTestCaseResult.ResultType.FAILURE || result.result1.Result == NuintTestCaseResult.ResultType.ERROR) && result.result2.Result == NuintTestCaseResult.ResultType.SUCCESS)
                    {
                        failureToSuccess++;
                    }
                }
            }
            body.AppendLine("<h2>" + "<b><u>Regression Summary</u></b>" + ": Success and Error to Failure: " + "<font color=\"red\"> <b>" + successToFailure + "</b> <font color=\"black\">" + " Failure and Error to Success: " + "<font color=\"green\"> <b>" + failureToSuccess + "</b> </h2>");
            body.AppendLine("<table border=\"1\">");
            body.AppendLine("<tr><td  bgcolor=\"grey\">TestCase Name</td><td bgcolor=\"grey\">Directory</td><td bgcolor=\"grey\">Previous</td><td bgcolor=\"grey\">Current</td></tr>");

            foreach (NunitDiffResult result in diff)
            {
                body.Append("<tr><td align=\"left\">");
                string testCaseName = ((result.result1 == null) ? result.result2.Name : result.result1.Name);


                body.Append("<font color=\"blue\">" + testCaseName);
                if (result.result1 != null)
                {
                    body.Append("<td align=\"left\"> " + result.result1.FileName + "</td>");
                }
                else
                {
                    body.Append("<td align=\"left\"> " + result.result2.FileName + "</td>");
                }
                body.AppendLine("</td><td>");

                if (result.result1 == null)
                {
                    body.Append("<font color=\"green\">Newly Added</font></td><td>");
                }
                else
                {
                    if (result.result1.Executed)
                    {
                        body.Append("<font color=\"green\">-Executed</font>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-Not Executed</font>");
                    }
                    if (result.result1.Result == NuintTestCaseResult.ResultType.SUCCESS)
                    {
                        body.Append("<font color=\"green\">-" + result.result1.Result.ToString() + "</font></td><td>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-" + result.result1.Result.ToString() + "</font></td><td>");
                    }
                }

                if (result.result2 == null)
                {
                    body.Append("<font color=\"red\">Deleted</font></td>");
                }
                else
                {
                    if (result.result2.Executed)
                    {
                        body.Append("<font color=\"green\">-Executed</font>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-Not Executed</font>");
                    }
                    if (result.result2.Result == NuintTestCaseResult.ResultType.SUCCESS)
                    {
                        body.Append("<font color=\"green\">-" + result.result2.Result.ToString() + "</font></td>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-" + result.result2.Result.ToString() + "</font></td>");
                    }
                }
            }
            body.AppendLine("</table>");
            Console.WriteLine("report creation over ");
        }
示例#5
0
        /// <summary>
        /// this function is to do the comparison
        /// </summary>
        /// <param name="result1">result1 is from previous xml </param>
        /// <param name="result2">result2 is from current xml </param>
        /// <returns></returns>
        public static List<NunitDiffResult> NuintDiff(NuintTestResult result1, NuintTestResult result2)
        {
            if (result1 == null || result2 == null)
                throw new ArgumentNullException("some arguments are null");

            List<NunitDiffResult> diff = new List<NunitDiffResult>();
            int ix1 = 0;
            int ix2 = 0;

            while (ix1 < result1.results.Count() && ix2 < result2.results.Count())
            {
                if (result1.results[ix1].Name == result2.results[ix2].Name)
                {
                    if (result1.results[ix1].Executed != result2.results[ix2].Executed || result1.results[ix1].Result != result2.results[ix2].Result)
                        diff.Add(new NunitDiffResult(result1.results[ix1], result2.results[ix2]));
                    ++ix1;
                    ++ix2;
                }
                else
                {
                    if (string.Compare(result1.results[ix1].Name, result2.results[ix2].Name) > 0)
                    {
                        diff.Add(new NunitDiffResult(null, result2.results[ix2]));
                        ++ix2;
                    }
                    else
                    {
                        diff.Add(new NunitDiffResult(result1.results[ix1], null));
                        ++ix1;
                    }
                }
            }

            if (ix1 != result1.results.Count())
            {
                for (; ix1 < result1.results.Count(); ++ix1)
                    diff.Add(new NunitDiffResult(result1.results[ix1], null));
            }
            else
            {
                for (; ix2 < result2.results.Count(); ++ix2)
                    diff.Add(new NunitDiffResult(null, result2.results[ix2]));
            }

            return diff;
        }
示例#6
0
        /// <summary>
        /// this function is to append the difference between xml files to the report
        /// </summary>
        /// <param name="curPath"></param>
        /// <param name="prePath"></param>
        /// <param name="body"></param>
        public static void AppendNuintDiff(string curPath, string prePath, ref StringBuilder body)
        {
            int successToFailure = 0, failureToSuccess = 0;
            if (body == null)
                body = new StringBuilder();
            if (prePath == null || curPath == null)
                return;

            NuintTestResult pre = new NuintTestResult(0, prePath);
            NuintTestResult cur = new NuintTestResult(0, curPath);

            if (pre.results == null || cur.results == null)
                return;
            else if (pre.results.Count == 0 || cur.results.Count == 0)
                return;

            List<NunitDiffResult> diff = NuintDiff(pre, cur);
            Console.WriteLine(diff.Count);
            if (diff.Count == 0)
            {
                Console.WriteLine("No Change in tests");
                body.AppendLine("<h4>" + "No Change in tests" + "<h4>");

                return;
            }
            Console.WriteLine("starting creation of report");
            foreach (NunitDiffResult result in diff)
            {
                if (result.result1 != null && result.result2 != null)
                {
                    if (result.result1.Result == NuintTestCaseResult.ResultType.SUCCESS && (result.result2.Result == NuintTestCaseResult.ResultType.FAILURE || result.result2.Result == NuintTestCaseResult.ResultType.ERROR))
                        successToFailure++;
                    if ((result.result1.Result == NuintTestCaseResult.ResultType.FAILURE || result.result1.Result == NuintTestCaseResult.ResultType.ERROR) && result.result2.Result == NuintTestCaseResult.ResultType.SUCCESS)
                        failureToSuccess++;
                }
            }
            body.AppendLine("<h2>" +"<b><u>Regression Summary</u></b>"+ ": Success and Error to Failure: " + "<font color=\"red\"> <b>" + successToFailure + "</b> <font color=\"black\">" + " Failure and Error to Success: " + "<font color=\"green\"> <b>" + failureToSuccess + "</b> </h2>");
            body.AppendLine("<table border=\"1\">");
            body.AppendLine("<tr><td  bgcolor=\"grey\">TestCase Name</td><td bgcolor=\"grey\">Directory</td><td bgcolor=\"grey\">Previous</td><td bgcolor=\"grey\">Current</td></tr>");

            foreach (NunitDiffResult result in diff)
            {
                body.Append("<tr><td align=\"left\">");
                string testCaseName = ((result.result1 == null) ? result.result2.Name : result.result1.Name);


                body.Append("<font color=\"blue\">" + testCaseName);
                if (result.result1 != null)
                    body.Append("<td align=\"left\"> " + result.result1.FileName + "</td>");
                else
                    body.Append("<td align=\"left\"> " + result.result2.FileName + "</td>");
                body.AppendLine("</td><td>");

                if (result.result1 == null)
                {
                    body.Append("<font color=\"green\">Newly Added</font></td><td>");
                }
                else
                {
                    if (result.result1.Executed)
                    {
                        body.Append("<font color=\"green\">-Executed</font>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-Not Executed</font>");
                    }
                    if (result.result1.Result == NuintTestCaseResult.ResultType.SUCCESS)
                    {
                        body.Append("<font color=\"green\">-" + result.result1.Result.ToString() + "</font></td><td>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-" + result.result1.Result.ToString() + "</font></td><td>");
                    }
                }

                if (result.result2 == null)
                {
                    body.Append("<font color=\"red\">Deleted</font></td>");
                }
                else
                {
                    if (result.result2.Executed)
                    {
                        body.Append("<font color=\"green\">-Executed</font>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-Not Executed</font>");
                    }
                    if (result.result2.Result == NuintTestCaseResult.ResultType.SUCCESS)
                    {
                        body.Append("<font color=\"green\">-" + result.result2.Result.ToString() + "</font></td>");
                    }
                    else
                    {
                        body.Append("<font color=\"red\">-" + result.result2.Result.ToString() + "</font></td>");
                    }
                }
            }
            body.AppendLine("</table>");
            Console.WriteLine("report creation over ");
        }