James Allman
James Allman

Reputation: 41168

Resharper/Nunit AssertionException was unhandled by user code

I am trying to set up unit testing in a solution with Visual Studio Enterprise 2015 and Resharper Ultimate 2015.2.

I created a new unit test project in the solution and used NuGet to install Nunit 2.6.4.

Debugging a unit test through Resharper throws an AssertionException. I expected it to catch the exception and report it.

For example:

[TestFixture]
class AssertTest
{
    [Test]
    public void IsTrue()
    {
        Assert.True(false);
    }
}

Is there additional configuration that needs to be done to properly integrate Resharper and Nunit?

Upvotes: 1

Views: 935

Answers (1)

terle
terle

Reputation: 86

Perhaps you need the "Unit Test Session" from Resharper. Get it by CTRL+ALT+R. From there you can right click and debug your unit tests

On second reading of your question I wonder if the scenario you're describing isn't exactly as expected? In your test you want to assert something to be TRUE. If it is, jolly-good -> continue. If it isn't, then you'd wanna know, hence the ASSERTIONException.

My point is, Tests should tell you if something is not as expected. And Assert.True(False) is doing just that.

If you wanna log, you could surround your assertions with try-catch, log the exception and just throw it. You should have the test fail, if something is not as expected.

Hope this was helpful.

Upvotes: 0

Related Questions