Example #1
0
        public void TestTestPassing()
        {
            ITestRunner testRunner = TestRunnerFactory.NewTestRunner();

            // The TestRunner cannot be null.
            Xunit.Assert.NotNull(testRunner);

            // Submit the job.
            ITestResult testResult = testRunner.RunTest(testRunner.NewJobRequestBuilder()
                                                        .AddDriverConfiguration(TestPassingStartHandler.GetDriverConfiguration())
                                                        .AddGlobalAssemblyForType(typeof(TestPassingStartHandler))
                                                        .SetJobIdentifier("TestPassingTest"));

            // The TestResult cannot be null.
            Xunit.Assert.NotNull(testResult);

            // The TestResult cannot contain a failed assert.
            Xunit.Assert.True(testResult.AllTestsSucceeded, testResult.FailedTestMessage);

            // The TestResult cannot contain more than one passed assert.
            Xunit.Assert.Equal(1, testResult.NumberOfPassedAsserts);
        }
Example #2
0
        public void TestTestFailure()
        {
            ITestRunner testRunner = TestRunnerFactory.NewTestRunner();

            // The TestRunner cannot be null.
            Xunit.Assert.NotNull(testRunner);

            // Submit the job.
            ITestResult testResult = testRunner.RunTest(testRunner.NewJobRequestBuilder()
                                                        .AddDriverConfiguration(TestFailingStartHandler.GetDriverConfiguration())
                                                        .AddGlobalAssemblyForType(typeof(TestFailingStartHandler))
                                                        .SetJobIdentifier("TestFailingTest"));

            // The TestResult cannot be null.
            Xunit.Assert.NotNull(testResult);

            // There should be at least 1 failing assert.
            Xunit.Assert.False(testResult.AllTestsSucceeded, testResult.FailedTestMessage);

            // Only the expected assert should have failed.
            Xunit.Assert.Equal(1, testResult.NumberOfFailedAsserts);
        }