コード例 #1
0
        public void RunTestsOfJUUTTestClassWithFailingClassSetUp()
        {
            TestClassSession session = new TestClassSession(typeof(TestClassMockWithFailingClassSetUp));
            session.Add(typeof(TestClassMockWithFailingClassSetUp).GetMethod("Bar"));

            //Testing the run of a specific testMethod
            TestRunner runner = new SimpleTestRunner();
            ClassReport classReport = runner.Run(session);
            AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningATestWithFailingClassSetUp();

            //Checking the returned test report
            Report report = GetFirstMethodReportFrom(classReport.MethodReports);
            Exception raisedException = new NullReferenceException("Failing class set up.");
            Report expectedReport = new MethodReport(typeof(TestClassMockWithFailingClassSetUp).GetMethod("ClassSetUp"), raisedException);
            AssertEx.That(report, Is.EqualTo(expectedReport));

            //Testing the run of all tests
            MethodCallOrder = new List<string>();
            session.AddAll();
            classReport = runner.Run(session);
            AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningATestWithFailingClassSetUp();

            //Checking the returned test reports
            ICollection<MethodReport> reports = classReport.MethodReports;
            raisedException = new NullReferenceException("Failing class set up.");
            expectedReport = new MethodReport(typeof(TestClassMockWithFailingClassSetUp).GetMethod("ClassSetUp"), raisedException);
            AssertEx.That(reports.Count, Is.EqualTo(1));
            AssertEx.That(GetFirstMethodReportFrom(reports), Is.EqualTo(expectedReport));
        }
コード例 #2
0
ファイル: AbstractTestSuite.cs プロジェクト: LennartH/JUUT
 public void RunSimpleTests(Session session)
 {
     TestRunner runner = new SimpleTestRunner();
     foreach (TestClassSession testClassSession in session.TestClassSessions) {
         Reporter.AddReport(runner.Run(testClassSession));
     }
     Reporter.PresentReports();
 }
コード例 #3
0
        public void RunSpecificTestOfJUUTTestClass()
        {
            TestClassSession session = new TestClassSession(typeof(TestClassMock));
            session.Add(typeof(TestClassMock).GetMethod("Foo"));

            TestRunner runner = new SimpleTestRunner();
            ClassReport classReport = runner.Run(session);
            AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningASpecificTest();

            //Checking the returned test report
            Report report = GetFirstMethodReportFrom(classReport.MethodReports);
            Report expectedReport = new MethodReport(typeof(TestClassMock).GetMethod("Foo"));
            AssertEx.That(report, Is.EqualTo(expectedReport));
        }
コード例 #4
0
        public void RunAllTestsOfJUUTTestClass()
        {
            TestClassSession session = new TestClassSession(typeof(TestClassMock));
            session.AddAll();

            TestRunner runner = new SimpleTestRunner();
            ClassReport classReport = runner.Run(session);
            AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningAllTests();

            //Checking the created test reports
            ICollection<MethodReport> resultReports = classReport.MethodReports;
            AssertEx.That(resultReports.Count, Is.EqualTo(2));
            foreach (MethodReport report in resultReports) {
                AssertThatTheReportIsEqualToFooOrBar(report);
            }
        }
コード例 #5
0
        public void RunTestsOfJUUTTestClassWithFailingTestMethod()
        {
            TestClassSession session = new TestClassSession(typeof(TestClassMockWithFailingTestMethod));
            session.AddAll();

            TestRunner runner = new SimpleTestRunner();
            ClassReport classReport = runner.Run(session);
            AssertThatTheMethodsAreCalledInTheCorrectOrderAfterRunningATestWithFailingTestMethod();

            //Checking the returned test reports
            ICollection<MethodReport> reports = classReport.MethodReports;

            ICollection<MethodReport> expectedReports = new HashSet<MethodReport>();
            expectedReports.Add(new MethodReport(typeof(TestClassMockWithFailingTestMethod).GetMethod("FailingTest"),
                new NullReferenceException("Failing test method.")));
            expectedReports.Add(new MethodReport(typeof(TestClassMockWithFailingTestMethod).GetMethod("WorkingTest")));

            AssertEx.That(reports.Count, Is.EqualTo(2));
            Assert.IsTrue(expectedReports.SequenceEqual(reports));
        }