NUnit / Testdriven.Net 冲突的结果

发布于 2024-08-30 05:40:28 字数 765 浏览 3 评论 0原文

当我在 NUnit = Red Bar 中运行此测试时。

    [Test]
    public void ChangingValueViaPropertyDescriptorRaisesPropertyChangedNotification()
    {
        PropertyChangedEventArgs pCEventArgs = null;
        subjectVM.PropertyChanged += (sender, e) => { pCEventArgs = e; };

        PropertyDescriptor descriptor = subjectVM.GetProperties().Find(schoolMeta.Name, false);

        descriptor.SetValue(null, "School's out for summer.");

        Assert.IsNotNull(pCEventArgs);
        Assert.AreEqual("School", pCEventArgs.PropertyName);
    }

但是,当我使用 Testdriven.Net 从 Visual Studio 中运行此测试时,它通过了(从控制台应用程序运行时也可以)。

当 NUnit 失败时,这是因为 PropertyChanged 为 null,subjectVM 是一个从基类继承 PropertyChanged 的​​视图模型类。

是我的错,还是我看到了 NUnit 的 bug?

When I run this test in NUnit = Red Bar.

    [Test]
    public void ChangingValueViaPropertyDescriptorRaisesPropertyChangedNotification()
    {
        PropertyChangedEventArgs pCEventArgs = null;
        subjectVM.PropertyChanged += (sender, e) => { pCEventArgs = e; };

        PropertyDescriptor descriptor = subjectVM.GetProperties().Find(schoolMeta.Name, false);

        descriptor.SetValue(null, "School's out for summer.");

        Assert.IsNotNull(pCEventArgs);
        Assert.AreEqual("School", pCEventArgs.PropertyName);
    }

However, when I run this test from within Visual Studio with Testdriven.Net it passes (it's also ok when run from a console app).

When it fails with NUnit it's because PropertyChanged is null, subjectVM is a View Model class that inherits PropertyChanged from a base class.

Am I to blame, or am I looking at a NUnit bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声情话 2024-09-06 05:40:28

不同的测试工具以不同的顺序执行测试:如果此测试对夹具的执行顺序有隐式依赖,则可能会导致此问题(我之前曾被此问题困扰过)。

我最好的猜测是,另一个测试正在对 subjectVM(或其一个成员)做一些可疑的事情。

Different test harnesses execute tests in different orders: if this test has an implicit dependency on the fixture's execution order, it could be causing this problem (I've been burned by this before).

My best guess is that another test is doing something fishy to subjectVM (or one of its members).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文