testfx icon indicating copy to clipboard operation
testfx copied to clipboard

Test Classes should support IAsyncDisposable in addition to IDisposable.

Open invino4 opened this issue 4 years ago • 0 comments

Description

IMPORTANT: if the defect is reproduced only in a workflow from within the Visual Studio IDE then do not report the issue here - instead, please report it using Visual Studio's "Send Feedback" option that can be accessed from the Help menu OR using this link https://developercommunity.visualstudio.com.

For a defect reproducable from the vstest command line, describe the issue you've observed.

Steps to reproduce

What steps can reproduce the defect? Please share the setup, commandline for vstest.console, sample project, target framework etc.

    [TestClass]
    public sealed class SomeTests : IAsyncDisposable
    {
        public ValueTask DisposeAsync()
        {
            // should be called during test cleanup.
        }
    }

Expected behavior

Share the expected output The DisposeAsync method should be called during test cleanup in the same manner as the Dispose method from IDisposable is called. Either Dispose, DisposeAsync or both can be implemented by the test class. If both are implemented then DisposeAsync should be preferred. Only one is actually called.

Actual behavior

What is the behavior observed? DisposeAsync is ignored and never executed. See code here.

Diagnostic logs

Please share test platform diagnostics logs. Instructions to collect logs are here.
The logs may contain test assembly paths, kindly review and mask those before sharing.

Environment

Please share additional details about the test environment. Operating system, Build version of vstest.console

invino4 avatar May 26 '20 21:05 invino4