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)); }
public void MethodManagement() { TestClassSession classSession = new TestClassSession(typeof(TestClassMock)); classSession.Add(typeof(TestClassMock).GetMethod("FirstTestMethod")); HashSet<MethodInfo> expectedMethods = new HashSet<MethodInfo> { typeof(TestClassMock).GetMethod("FirstTestMethod") }; Assert.IsTrue(expectedMethods.SetEquals(classSession.TestsToRun)); classSession.AddAll(); expectedMethods.Add(typeof(TestClassMock).GetMethod("SecondTestMethod")); Assert.IsTrue(expectedMethods.SetEquals(classSession.TestsToRun)); }
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)); }
public void MethodAdding() { TestClassSession session = new TestClassSession(typeof(ThirdTestClassMock)); AssertEx.That(() => session.Add(typeof(AnotherTestClassMock).GetMethod("TestMethod")), Throws.An<ArgumentException>()); AssertEx.That(() => session.Add(typeof(ThirdTestClassMock).GetMethod("NotAttributedMethod")), Throws.An<ArgumentException>()); }