Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestMethod failures are masked by TestCleanup exceptions in the outcome. #58

Closed
AbhitejJohn opened this issue Feb 7, 2017 · 6 comments
Assignees
Milestone

Comments

@AbhitejJohn
Copy link
Contributor

Description

Failures in the TestMethod are masked by TestCleanup exceptions in the outcome.

Steps to reproduce

  1. Create an MSTest V2 based unit test project.
  2. Throw an exception in the TestMethod and the TestCleanup.
  3. Run the test.

Expected behavior

An indication of the test method exception and stack trace should be shown in the outcome.

Actual behavior

Only the TestCleanup stack is shown.

@AbhitejJohn
Copy link
Contributor Author

Code that affects this change is at src\testadapter\execution\testmethodinfo.RunTestCleanupMethod().
Need to decide if this is something we want to combine or do we just want to show the testmethod exception details.

@pvlakshm
Copy link
Contributor

This happens only when the TestMethod fails AND the TestCleanup method fails.

@AbhitejJohn
Copy link
Contributor Author

Reopening this - This is both misleading and is a compat break from MSTest V1 which displays both the details. For instance with the below code

[TestMethod]
        public void TestMethod1()
        {
            Assert.Inconclusive();
        }

        [TestCleanup]
        public void TC()
        {
            throw new NullReferenceException();
        }

this is the error info in Test Explorer.
testcleanupissues

@smadala
Copy link
Contributor

smadala commented May 3, 2017

Customer are hitting this issue: Assembly load failures in TestInitialize() are not getting reported When there is failure in TestCleanup().

@kevintbrown
Copy link

kevintbrown commented May 4, 2017

I'd also like to add that when Debugging a single test in Visual Studio 2017, there is no exposure to the user that the [TestInitialize()] and [TestMethod()] attributed methods are even executed (you can put breakpoints at the top of each method and they are skipped).

Next thing you know an exception is thrown in [TestCleanup()], which makes it really hard to debug your underlying issue. I had to engage the MSTest team to figure out what was going on.

(Thanks again for the help!)

@smadala
Copy link
Contributor

smadala commented May 4, 2017

Enable logging also helps to find root cause,following blog post helps how to enable logging enable unit test execution logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants