Example #1
0
            public void ReturnsTheExpectedTestRunResults()
            {
                var startTime = new DateTime(2019, 10, 01, 14, 31, 42, DateTimeKind.Utc);
                var endTime   = new DateTime(2019, 10, 01, 14, 31, 55, DateTimeKind.Utc);
                var duration  = 12.351793;

                var     fixture = new NUnit3XmlReaderFixture();
                TestRun results = fixture.ParseTestRunResultsNUnit3();

                Assert.AreEqual(results.Total, 18, "Wrong total amount");
                Assert.AreEqual(results.Passed, 12, "Wrong passed amount");
                Assert.AreEqual(results.Failed, 2, "Wrong failed amount");
                Assert.AreEqual(results.Inconclusive, 1, "Wrong inconclusive amount");
                Assert.AreEqual(results.Skipped, 3, "Wrong skipped amount");

                Assert.AreEqual(results.Passed, results.TestCases.Count(x => x.Result == Result.Passed), "Wrong passed test cases amount");
                Assert.AreEqual(results.Failed, results.TestCases.Count(x => x.Result == Result.Failed), "Wrong failed test cases amount");
                Assert.AreEqual(results.Inconclusive, results.TestCases.Count(x => x.Result == Result.Inconclusive), "Wrong inconclusive test cases amount");
                Assert.AreEqual(results.Skipped, results.TestCases.Count(x => x.Result == Result.Skipped), "Wrong skipped test cases amount");

                var fullName = "NUnit.Tests.Assemblies.MockTestFixture.MockTest3";
                var testCase = results.TestCases.SingleOrDefault(x => x.FullName == fullName);

                Assert.NotNull(testCase, $"Could not find test case with full name '{fullName}'");

                Assert.AreEqual(fullName, testCase.FullName, "Unexpected full name");
                Assert.AreEqual(Result.Passed, testCase.Result, "Unexpected result");
                Assert.AreEqual(DateTimeKind.Utc, testCase.StartTime.Kind, "Start time isn't UTC");
                Assert.AreEqual(DateTimeKind.Utc, testCase.EndTime.Kind, "End time isn't UTC");
                Assert.AreEqual(startTime, testCase.StartTime, "Unexpected start time");
                Assert.AreEqual(endTime, testCase.EndTime, "Unexpected end time");
                Assert.AreEqual(duration, testCase.Duration.TotalSeconds, .001, "Unexpected duration");
            }
Example #2
0
            public void ThrowsIfFilePathIsNull()
            {
                var fixture = new NUnit3XmlReaderFixture();

                var exception = Assert.Throws <ArgumentNullException>(() => fixture.ParseTestRunResultsNull());

                Assert.AreEqual("testResultsPath", exception.ParamName);
            }
Example #3
0
            public void ThrowsIfItHasADuplicateTestName()
            {
                var fixture = new NUnit3XmlReaderFixture();

                Assert.Throws <CakeException>(() => fixture.ParseTestRunResultsNUnit3DuplicateTestName());
            }
Example #4
0
            public void ThrowsIfWrongFileFormatIsUsed()
            {
                var fixture = new NUnit3XmlReaderFixture();

                Assert.Throws <XmlParsingException>(() => fixture.ParseTestRunResultsNUnit2());
            }
Example #5
0
            public void ThrowsIfFilePathDoesntExist()
            {
                var fixture = new NUnit3XmlReaderFixture();

                var exception = Assert.Throws <CakeException>(() => fixture.ParseTestRunResultsNonExistant());
            }