Why is my NUnit test failing?

I added an NUNit test (NUnit newby here):

[Test]
public void TestHHSDeliveryInterface()
{
    var Delivery = IOC.container.Resolve<IHHSDelivery>();

    var i = Delivery.GetCount();

    Assert.Greater(i, 16);
}

...based on an existing one that works:

[Test]
public void TestHHSInterface()
{
    var HHSClient = IOC.container.Resolve<IHHSClient>();

    var s = HHSClient.GetTestMessage("Dom", "Paz");

    Assert.Greater(s.Value.Length, 0);
}

...for some context, the class starts this way:

[TestFixture, Category(SSCSCOMMON.UnitTests.Categories.IntegrationTest)]
public class HHSClientIntegrationTests
{

The method (Delivery.GetCount();) is returning a "canned" value (17) for now. So it itself works. So why is the test failing? Unfortunately, the test code is not breakpointable - at least, I have a breakpoint in it, and it doesn't ever get reached, which it should if it's failing, I would think, normally. NUnit looks like this after I run the app and the tests:

enter image description here

With the problematic test commented out, the others run fine.

UPDATE

It turns out that solving this problem also solved this one.

Upvotes: 1

Views: 368

Answers (1)

Peter
Peter

Reputation: 27934

Using my psychic debug skills:

So why is the test failing? Unfortunately, the test code is not breakpointable - at least, I have a breakpoint in it, and it doesn't ever get reached, which it should if it's failing, I would think, normally.

You are not running the unit test on the dll you think you are debugging. I guess your debug breakpoint tells you the code you are running differs form the source code. Clean your deployment directories/ and your project (all dlls) and recompile.

Upvotes: 1

Related Questions