Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public void RunSimpleTests(Session session)
 {
     TestRunner runner = new SimpleTestRunner();
     foreach (TestClassSession testClassSession in session.TestClassSessions) {
         Reporter.AddReport(runner.Run(testClassSession));
     }
     Reporter.PresentReports();
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
        }