NUnit / Testdriven.Net 冲突的结果
当我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不同的测试工具以不同的顺序执行测试:如果此测试对夹具的执行顺序有隐式依赖,则可能会导致此问题(我之前曾被此问题困扰过)。
我最好的猜测是,另一个测试正在对 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).