private static IXunitTestCase[] TestCases(IAssemblyInfo assemblyInfo) { using var discoverySink = new TestDiscoverySink(); using var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, SourceInformationProvider, DiagnosticMessageSink); discoverer.Find(false, discoverySink, TestFrameworkOptions.ForDiscovery()); discoverySink.Finished.WaitOne(); return(discoverySink.TestCases.Cast <IXunitTestCase>().ToArray()); }
public RealDiscovery() { var sourceInformationProvider = new NullSourceInformationProvider(); var diagnosticMessageSink = new Xunit.NullMessageSink(); var assembly = typeof(TestCaseBulkDeserializerTests).Assembly; var assemblyInfo = Reflector.Wrap(assembly); discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceInformationProvider, diagnosticMessageSink); var discoverySink = new SpyMessageSink <IDiscoveryCompleteMessage>(); discoverer.Find("TestCaseDescriptorFactoryTests+TestClass", false, discoverySink, TestFrameworkOptions.ForDiscovery()); discoverySink.Finished.WaitOne(); testCases = discoverySink.Messages.OfType <ITestCaseDiscoveryMessage>().Select(m => m.TestCase).ToList(); }
public static void TheoryWithNonSerializableData_ReturnsAsASingleTestCase() { var sourceProvider = new NullSourceInformationProvider(); var assemblyInfo = Reflector.Wrap(Assembly.GetExecutingAssembly()); var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceProvider); var visitor = new TestDiscoveryVisitor(); discoverer.Find(typeof(ClassWithNonSerializableTheoryData).FullName, false, visitor, TestFrameworkOptions.ForDiscovery()); visitor.Finished.WaitOne(); var testCase = Assert.Single(visitor.TestCases); Assert.IsType <XunitTheoryTestCase>(testCase); var deserialized = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(testCase)); Assert.IsType <XunitTheoryTestCase>(deserialized); }
public static void TheoriesAlwaysComeBackAsSingleXunitTheoryTestCase() { var sourceProvider = new NullSourceInformationProvider(); var assemblyInfo = Reflector.Wrap(Assembly.GetExecutingAssembly()); var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceProvider); var visitor = new TestDiscoveryVisitor(); discoverer.Find(typeof(ClassWithTheory).FullName, false, visitor, new XunitDiscoveryOptions()); visitor.Finished.WaitOne(); var testCase = Assert.Single(visitor.TestCases); Assert.IsType <XunitTheoryTestCase>(testCase); var deserialized = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(testCase)); Assert.IsType <XunitTheoryTestCase>(deserialized); }
public static void SerializedTestsInSameCollectionRemainInSameCollection() { var sourceProvider = new NullSourceInformationProvider(); var assemblyInfo = Reflector.Wrap(Assembly.GetExecutingAssembly()); var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceProvider); var visitor = new TestDiscoveryVisitor(); discoverer.Find(typeof(ClassUnderTest).FullName, false, visitor, new XunitDiscoveryOptions()); visitor.Finished.WaitOne(); var first = visitor.TestCases[0]; var second = visitor.TestCases[1]; Assert.True(TestCollectionComparer.Instance.Equals(first.TestCollection, second.TestCollection)); var serializedFirst = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(first)); var serializedSecond = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(second)); Assert.NotSame(serializedFirst.TestCollection, serializedSecond.TestCollection); Assert.True(TestCollectionComparer.Instance.Equals(serializedFirst.TestCollection, serializedSecond.TestCollection)); }
public static void TheoriesWithSerializableData_ReturnAsIndividualTestCases() { var sourceProvider = new NullSourceInformationProvider(); var assemblyInfo = Reflector.Wrap(Assembly.GetExecutingAssembly()); var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceProvider); var visitor = new TestDiscoveryVisitor(); discoverer.Find(typeof(ClassWithTheory).FullName, false, visitor, TestFrameworkOptions.ForDiscovery()); visitor.Finished.WaitOne(); var first = visitor.TestCases[0]; var second = visitor.TestCases[1]; Assert.NotEqual(first.UniqueID, second.UniqueID); Assert.True(TestCollectionComparer.Instance.Equals(first.TestMethod.TestClass.TestCollection, second.TestMethod.TestClass.TestCollection)); var serializedFirst = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(first)); var serializedSecond = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(second)); Assert.NotSame(serializedFirst.TestMethod.TestClass.TestCollection, serializedSecond.TestMethod.TestClass.TestCollection); Assert.True(TestCollectionComparer.Instance.Equals(serializedFirst.TestMethod.TestClass.TestCollection, serializedSecond.TestMethod.TestClass.TestCollection)); }
public void Find(bool includeSourceInformation, IMessageSink discoveryMessageSink, ITestFrameworkDiscoveryOptions discoveryOptions) { _xunitTestFrameworkDiscoverer .Find ( includeSourceInformation, new FilterableMessageSink ( discoveryMessageSink, message => { if (message is TestCaseDiscoveryMessage discoveryMessage && discoveryMessage.TestMethod.Method.IsIntegrationTest()) { return(null); } if (message is DiscoveryCompleteMessage) { _integrationTestFrameworkDiscoverer.Find(includeSourceInformation, discoveryMessageSink, discoveryOptions); return(null); } return(message); }
public static void SerializedTestsInSameCollectionRemainInSameCollection() { var sourceProvider = new NullSourceInformationProvider(); var assemblyInfo = Reflector.Wrap(Assembly.GetExecutingAssembly()); var discoverer = new XunitTestFrameworkDiscoverer(assemblyInfo, sourceProvider, SpyMessageSink.Create()); var sink = new TestDiscoverySink(); discoverer.Find(typeof(ClassWithFacts).FullName, false, sink, TestFrameworkOptions.ForDiscovery()); sink.Finished.WaitOne(); var first = sink.TestCases[0]; var second = sink.TestCases[1]; Assert.NotEqual(first.UniqueID, second.UniqueID); Assert.True(TestCollectionComparer.Instance.Equals(first.TestMethod.TestClass.TestCollection, second.TestMethod.TestClass.TestCollection)); var serializedFirst = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(first)); var serializedSecond = SerializationHelper.Deserialize <ITestCase>(SerializationHelper.Serialize(second)); Assert.NotSame(serializedFirst.TestMethod.TestClass.TestCollection, serializedSecond.TestMethod.TestClass.TestCollection); Assert.True(TestCollectionComparer.Instance.Equals(serializedFirst.TestMethod.TestClass.TestCollection, serializedSecond.TestMethod.TestClass.TestCollection)); }