作者:mobiledu2502862217 | 来源:互联网 | 2023-10-11 20:07
ThistestfailswhenitisrunwiththeNUnitconsolerunner.ItworksifIrunjustthattestwith
This test fails when it is run with the NUnit console runner. It works if I run just that test with TestDriven.NET, but not if I run the entire suite with TestDriven.NET:
使用NUnit控制台运行程序运行时,此测试失败。如果我使用TestDriven.NET运行该测试,它会起作用,但如果我使用TestDriven.NET运行整个套件则不行:
[Test]
public void BackgroundWorkerFiresRunWorkerCompleted()
{
var runner = new BackgroundWorker();
ManualResetEvent dOne= new ManualResetEvent(false);
runner.RunWorkerCompleted += delegate { done.Set(); };
runner.RunWorkerAsync();
bool res = done.WaitOne(TimeSpan.FromSeconds(10));
// This assert fails:
Assert.IsTrue(res, "RunWorkerCompleted was not executed within 10 seconds");
}
I suspect the problem have something to do with not having a message-loop, but I am not sure.
我怀疑这个问题与没有消息循环有关,但我不确定。
What are the requirements for using BackgroundWorker?
使用BackgroundWorker有哪些要求?
Is there a workaround to make the test work?
是否有解决方法使测试工作?
3 个解决方案