【问题标题】:Nunit TestCaseSource skips some casesNunit TestCaseSource 跳过一些案例
【发布时间】:2016-08-01 16:57:15
【问题描述】:

我正在研究 C# 程序、VS2015、R#、Nunit。我有 Nunit 测试

    [ Test ]
    [ TestCaseSource( typeof( GeneralTestCases ), "TestStoresCredentials" ) ]
    public void PingSoapAsync_IncorrectUrl_ThrowException( ServiceSoapCredentials credentials )

    [ Test ]
    [ TestCaseSource( typeof( GeneralTestCases ), "TestStoresCredentials" ) ]
    public void PingSoapAsync_IncorrectApiUser_ThrowException( ServiceSoapCredentials credentials )

GeneralTestCases 是(有 5 个案例!!!):

public class GeneralTestCases
{
    /// <summary>
    /// GetTestStoresCredentials shoud return the same credentials as this method
    /// </summary>
    /// <returns></returns>
    public IEnumerable TestStoresCredentials
    {
        get
        {
            yield return new TestCaseData(new BaseTest.MServiceSoapCredentials()).SetName("m1-9-2-0-ce");
            yield return new TestCaseData(new BaseTest.MServiceSoapCredentials()).SetName("m1-9-2-1-ce");
            yield return new TestCaseData(new BaseTest.MServiceSoapCredentials() ).SetName("m1-9-2-2-ce");
            yield return new TestCaseData(new BaseTest.MServiceSoapCredentials() ).SetName("m2-0-2-0-ce");
            yield return new TestCaseData(new BaseTest.MServiceSoapCredentials() ).SetName("m1-8-1-0-ce");
        }


    }
}

但是当我按下“运行所有测试”时,Resharper 测试运行器使用的并非所有案例:

我做错了什么?

【问题讨论】:

  • 如果您使用 NUnit 本身运行测试会发生什么?

标签: unit-testing tdd nunit resharper testcasesource


【解决方案1】:

此问题可能与您的测试运行程序有关。尝试关闭当前的测试会话并从头开始测试。R#-&gt; Unit Tests -&gt; Run Unit Tests

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    相关资源
    最近更新 更多