NUnit 2.5在Visual Studio中返回不确定的状态

Hen*_*sel 1 c# nunit unit-testing visual-studio

所以'我正在接受单元测试.我创建了一个非常简单的函数来测试它.

    public int MultiplyByFive(int x)
    {
        return x * 5;
    }
Run Code Online (Sandbox Code Playgroud)

测试方法包含

    [TestMethod()]
    [DeploymentItem("UnitTestApp.exe")]
    public void MultiplyByFiveTest()
    {
        Program_Accessor target = new Program_Accessor(); // TODO: Initialize to an appropriate value
        int x = 5; // TODO: Initialize to an appropriate value
        int expected = 25; // TODO: Initialize to an appropriate value
        int actual;
        actual = target.MultiplyByFive(x);
        Assert.AreEqual(expected, actual);
        Assert.Inconclusive("Verify the correctness of this test method.");
    }
Run Code Online (Sandbox Code Playgroud)

但是当我运行测试时,它会返回:

nunit http://dl.getdropbox.com/u/357576/nunit.jpg

"Assert.Inconclusive失败.验证此测试方法的正确性."

那么我做错了什么?谢谢!

ant*_*ony 5

NUnit 2.5在成功和失败之间增加了"不确定"的结果状态.这里的发行说明中对此进行了解释.

NUnit完全按照你的要求去做.新的不确定状态确实终止了测试.如果要在Assert失败的情况下显示消息,Assert.AreEqual()会有一个带有消息字符串的重载.使用它,并删除Assert.Inconclusive().

Assert.AreEqual(expected, actual, "Verify the correctness of this test method.");
Run Code Online (Sandbox Code Playgroud)