public void AssemblyHasNoTestAssemblyFixture() { AssemblyFactory.Type = typeof(ATestAssembly); var ta = new TestAssembly(new AssemblyName("ATestAssembly")); ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.Contains("TheOnlyTestInThisAssembly", SimpleTestListener.Messages); }
public void TestFixtureNestedInIgnoredTestFixture() { AssemblyFactory.Type = typeof(ASpecialAssembly); var assembly = new TestAssembly(new AssemblyName("bla")); assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.DoesNotContain("Bar", SimpleTestListener.Messages); }
public void IgnoredTestFixtureIsReported() { AssemblyFactory.Type = typeof(ASpecialAssembly); var assembly = new TestAssembly(new AssemblyName("bla")); assembly.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); Assert.Contains(GetType().Assembly.FullName + "#csUnit.Core.Tests.TestAssemblyTests+IgnoredFixture##Ignored for testing reasons.#", SimpleTestListener.IgnoredItems); }
public void IgnoreAppliedOnlyAfterTestSpec() { AssemblyFactory.Type = typeof(ASpecialAssembly); var assembly = new TestAssembly(new AssemblyName("bla")); // The fixture is actually in category "Blue"! assembly.RunTests(new TestRun(new CategoryCriterion("Green")), new SimpleTestListener()); Assert.Equals(0, SimpleTestListener.IgnoredItems.Length, "Ignored tests that were not specified."); }
public void TearDownThrowsException() { var consoleOutput = new StringWriter(); AssemblyFactory.Type = typeof(ATestAssembly); ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInTearDown); var ta = new TestAssembly(new AssemblyName("ATestAssembly")); Console.SetOut(consoleOutput); ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); var expected = "Executing " + GetType().FullName + @"+ATestAssembly+ATestClass.TheOnlyTestInThisAssembly()" + LineFeed + "Error: Exception thrown in TearDown method of TestAssemblyFixture:" + LineFeed + " Assembly might not properly tear down used resources. Error details follow." + LineFeed + "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName + @".TearDown()" + LineFeed; Assert.Contains(expected, consoleOutput.ToString()); }
public void HasPrivateDefaultConstructorOnly() { var consoleOutput = new StringWriter(); AssemblyFactory.Type = typeof(ATestAssembly); ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureWithPrivateConstructor); var ta = new TestAssembly(new AssemblyName("ATestAssembly")); Console.SetOut(consoleOutput); ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); var expected = "Warning: no public parameterless constructor found for class:" + LineFeed + " " + ATestAssembly.AssemblyFixtureType.FullName + LineFeed + " TestAssemblyFixture will be ignored"; Assert.Contains(expected, consoleOutput.ToString()); }
public void SetUpThrowsException() { var consoleOutput = new StringWriter(); AssemblyFactory.Type = typeof(ATestAssembly); ATestAssembly.AssemblyFixtureType = typeof(AssemblyFixtureThrowsInSetUp); var ta = new TestAssembly(new AssemblyName("ATestAssembly")); Console.SetOut(consoleOutput); ta.RunTests(new TestRun(new AllTestsCriterion()), new SimpleTestListener()); var expected = "Error: Exception thrown in SetUp method of TestAssemblyFixture:" + LineFeed + " Tests depending on it might fail. Error details follow." + LineFeed + "Exception thrown in " + ATestAssembly.AssemblyFixtureType.FullName + @".SetUp()"; Assert.Contains(expected, consoleOutput.ToString()); }