【问题标题】:MSTest 2.0 DataTestMethod swaping parameters orderMSTest 2.0 DataTestMethod 交换参数顺序
【发布时间】:2021-06-09 17:15:15
【问题描述】:

一般来说,我对 C# 和 MSTest 有点陌生,我正在尝试使用 DynamicData 属性进行参数化单元测试,看起来参数在运行时正在交换,这是我的测试的 sn-p:

     [TestClass]
     public class SampleTest
     {
         private TestContext testContextInstance;

         public TestContext TestContext
         {
            get { return testContextInstance; }
            set { testContextInstance = value; }
         }
         private static IEnumerable<object[]> ReusableTestData =>
                        new List<object[]> {
                        new object[] { 1, 2, 3 },
                        new object[] { 4, 5, 6 }
                };
         [DataTestMethod]
         [DynamicData(nameof(ReusableTestData))]
         public void Test1(int param1, int param2, int param3 )
         {
            TestContext.WriteLine($"{param1} {param2} {param3}");
         }

在控制台上,在第一个测试中我得到:

1 2 3

在第二次测试中我得到:

6 5 4

我在这里缺少一些配置吗?还是关于 MSTest 及其参数化测试的已知问题?

【问题讨论】:

标签: c# unit-testing mstest


【解决方案1】:

问题似乎是因为我将 TestFramework 库更新到了 V2.2.4。 通过将该库降级到 V2.0.0,我可以再次编译。

【讨论】:

    猜你喜欢
    • 2013-04-02
    • 2023-03-10
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 2015-10-05
    • 1970-01-01
    相关资源
    最近更新 更多