public void TestMethodCleanupFailure()
        {
            var methodStarting = new _TestMethodStarting
            {
                AssemblyUniqueID       = assemblyID,
                TestClassUniqueID      = classID,
                TestCollectionUniqueID = collectionID,
                TestMethod             = "MyMethod",
                TestMethodUniqueID     = methodID,
            };
            var methodCleanupFailure = new _TestMethodCleanupFailure
            {
                AssemblyUniqueID       = assemblyID,
                ExceptionParentIndices = exceptionParentIndices,
                ExceptionTypes         = exceptionTypes,
                Messages               = messages,
                StackTraces            = stackTraces,
                TestCollectionUniqueID = collectionID,
                TestClassUniqueID      = classID,
                TestMethodUniqueID     = methodID
            };
            var handler = TestableDefaultRunnerReporterMessageHandler.Create();

            handler.OnMessage(methodStarting);
            handler.OnMessage(methodCleanupFailure);

            AssertFailureMessages(handler.Messages, "Test Method Cleanup Failure (MyMethod)");
        }
Пример #2
0
        public async ValueTask TestMethodCleanupFailure()
        {
            var methodStarting = new _TestMethodStarting
            {
                AssemblyUniqueID       = assemblyID,
                TestClassUniqueID      = classID,
                TestCollectionUniqueID = collectionID,
                TestMethod             = "MyMethod",
                TestMethodUniqueID     = methodID,
            };
            var methodCleanupFailure = new _TestMethodCleanupFailure
            {
                AssemblyUniqueID       = assemblyID,
                ExceptionParentIndices = exceptionParentIndices,
                ExceptionTypes         = exceptionTypes,
                Messages               = messages,
                StackTraces            = stackTraces,
                TestCollectionUniqueID = collectionID,
                TestClassUniqueID      = classID,
                TestMethodUniqueID     = methodID
            };
            var listener = Substitute.For <ITestListener>();

            await using var sink = new ResultSink(listener, 42)
                        {
                            TestRunState = TestRunState.NoTests
                        };

            sink.OnMessage(methodStarting);
            sink.OnMessage(methodCleanupFailure);

            AssertFailure(listener, sink.TestRunState, "Test Method Cleanup Failure (MyMethod)");
        }
    public void TestMethodCleanupFailure()
    {
        var methodStarting = new _TestMethodStarting
        {
            AssemblyUniqueID       = assemblyID,
            TestClassUniqueID      = classID,
            TestCollectionUniqueID = collectionID,
            TestMethod             = "MyMethod",
            TestMethodUniqueID     = methodID,
        };
        var methodCleanupFailure = new _TestMethodCleanupFailure
        {
            AssemblyUniqueID       = assemblyID,
            ExceptionParentIndices = exceptionParentIndices,
            ExceptionTypes         = exceptionTypes,
            Messages               = messages,
            StackTraces            = stackTraces,
            TestCollectionUniqueID = collectionID,
            TestClassUniqueID      = classID,
            TestMethodUniqueID     = methodID
        };
        var assemblyElement = new XElement("assembly");
        var sink            = new DelegatingXmlCreationSink(innerSink, assemblyElement);

        sink.OnMessage(methodStarting);
        sink.OnMessage(methodCleanupFailure);

        AssertFailureElement(assemblyElement, "test-method-cleanup", "MyMethod");
    }