Exemple #1
0
        private void ParseResultsCount()
        {
            List <string> output = LoadOutput();

            List <RedGreen.TestResult> results = NUnitParser.ParseTestResults(output);

            Assert.Equal(6, results.Count);
        }
Exemple #2
0
        public void PublishNUnitResultFile()
        {
            SetupMocks();
            string nUnitBasicResultsXml =
                "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
                "<!--This file represents the results of running a test suite-->" +
                "<test-results name=\"C:\\testws\\mghost\\projvc\\TBScoutTest1\\bin\\Debug\\TBScoutTest1.dll\" total=\"3\" errors=\"0\" failures=\"1\" not-run=\"0\" inconclusive=\"0\" ignored=\"0\" skipped=\"0\" invalid=\"0\" date=\"2015-04-15\" time=\"12:25:14\">" +
                "  <environment nunit-version=\"2.6.4.14350\" clr-version=\"2.0.50727.8009\" os-version=\"Microsoft Windows NT 6.2.9200.0\" platform=\"Win32NT\" cwd=\"D:\\Software\\NUnit-2.6.4\\bin\" machine-name=\"MGHOST\" user=\"madhurig\" user-domain=\"REDMOND\" />" +
                "  <culture-info current-culture=\"en-US\" current-uiculture=\"en-US\" />" +
                "  <test-suite type=\"Assembly\" name=\"C:\\testws\\mghost\\projvc\\TBScoutTest1\\bin\\Debug\\TBScoutTest1.dll\" executed=\"True\" result=\"Failure\" success=\"False\" time=\"0.059\" asserts=\"0\">" +
                "    <results>" +
                "      <test-suite type=\"Namespace\" name=\"TBScoutTest1\" executed=\"True\" result=\"Failure\" success=\"False\" time=\"0.051\" asserts=\"0\">" +
                "        <results>" +
                "          <test-suite type=\"TestFixture\" name=\"ProgramTest1\" executed=\"True\" result=\"Failure\" success=\"False\" time=\"0.050\" asserts=\"0\">" +
                "            <results>" +
                "              <test-case name=\"TBScoutTest1.ProgramTest1.MultiplyTest\" executed=\"True\" result=\"Success\" success=\"True\" time=\"-0.027\" asserts=\"1\" />" +
                "              <test-case name=\"TBScoutTest1.ProgramTest1.SumTest\" executed=\"True\" result=\"Success\" success=\"True\" time=\"0.000\" asserts=\"1\" />" +
                "              <test-case name=\"TBScoutTest1.ProgramTest1.TestSumWithZeros\" executed=\"True\" result=\"Failure\" success=\"False\" time=\"0.009\" asserts=\"1\">" +
                "                <failure>" +
                "                  <message><![CDATA[  TBScout.Program.Sum did not return the expected value." +
                "  Expected: 0" +
                "  But was:  25" +
                "]]></message>" +
                "                  <stack-trace><![CDATA[at TBScoutTest1.ProgramTest1.TestSumWithZeros() in C:\\testws\\mghost\\projvc\\TBScoutTest1\\ProgramTest1.cs:line 63" +
                "]]></stack-trace>" +
                "                </failure>" +
                "              </test-case>" +
                "            </results>" +
                "          </test-suite>" +
                "        </results>" +
                "      </test-suite>" +
                "    </results>" +
                "  </test-suite>" +
                "</test-results>";

            string           resultFile      = TestUtil.WriteAllTextToTempFile(nUnitBasicResultsXml, "xml");
            NUnitParser      reader          = new NUnitParser();
            TestRunContext   runContext      = new TestRunContext();
            TestDataProvider runDataProvider = reader.ParseTestResultFiles(_ec.Object, runContext, new List <string> {
                resultFile
            });
            List <TestRunData> runData = runDataProvider.GetTestRunData();

            Assert.NotNull(runData[0].TestResults);
            Assert.Equal("C:\\testws\\mghost\\projvc\\TBScoutTest1\\bin\\Debug\\TBScoutTest1.dll", runData[0].RunCreateModel.Name);
            Assert.Equal(3, runData[0].TestResults.Count);
            Assert.Equal(2, runData[0].TestResults.Count(r => r.Outcome.Equals("Passed")));
            Assert.Equal(1, runData[0].TestResults.Count(r => r.Outcome.Equals("Failed")));
            Assert.Equal(1, runData[0].AttachmentsFilePathList.Count);

            Assert.Equal(null, runData[0].TestResults[0].AutomatedTestId);
            Assert.Equal(null, runData[0].TestResults[0].AutomatedTestTypeId);
            CleanupTempFile(resultFile);
        }
Exemple #3
0
        private void ValidateSkipped()
        {
            List <string> output = LoadOutput();

            List <RedGreen.TestResult> results = NUnitParser.ParseTestResults(output);

            RedGreen.TestResult alwaysFail = results.Find(r => r.Location == "RedGreenPlayground.NUnitTests.Skipped");

            Assert.Equal("RedGreenPlayground.NUnitTests.Skipped", alwaysFail.Location);
            Assert.Equal(RedGreen.TestStatus.Skipped, alwaysFail.Status);
        }
Exemple #4
0
        private void ParseSummary()
        {
            List <string> output = LoadOutput();

            SummaryResult result = NUnitParser.ParseSummary(output);

            Assert.Equal("5", result.TotalCount);
            Assert.Equal("1", result.PassCount);
            Assert.Equal("4", result.FailCount);
            Assert.Equal("1", result.SkipCount);
            Assert.Equal(String.Empty, result.Duration);
        }
Exemple #5
0
        private void ValidateIntFail()
        {
            List <string> output = LoadOutput();

            List <RedGreen.TestResult> results = NUnitParser.ParseTestResults(output);

            RedGreen.TestResult alwaysFail = results.Find(r => r.Location == "RedGreenPlayground.NUnitTests.IntFail");

            Assert.Equal("RedGreenPlayground.NUnitTests.IntFail", alwaysFail.Location);
            Assert.Equal(RedGreen.TestStatus.Failed, alwaysFail.Status);
            Assert.Equal("0", alwaysFail.Failure.Expected);
            Assert.Equal("1", alwaysFail.Failure.Actual);
            Assert.Equal(0, alwaysFail.Failure.ActualDiffersAt);
        }
Exemple #6
0
        private void ValidateAlwaysFail()
        {
            List <string> output = LoadOutput();

            List <RedGreen.TestResult> results = NUnitParser.ParseTestResults(output);

            RedGreen.TestResult alwaysFail = results.Find(r => r.Location == "RedGreenPlayground.NUnitTests.AlwaysFails");

            Assert.Equal("RedGreenPlayground.NUnitTests.AlwaysFails", alwaysFail.Location);
            Assert.Equal(RedGreen.TestStatus.Failed, alwaysFail.Status);
            Assert.Equal("0.019", alwaysFail.Duration);
            Assert.Equal("\"who's there\"", alwaysFail.Failure.Expected);
            Assert.Equal("\"who's where\"", alwaysFail.Failure.Actual);
            Assert.Equal(6, alwaysFail.Failure.ActualDiffersAt);
        }