Gallio DynamicTestFactory 和断言
我正在尝试使用 MbUnit 中的 DynamicTestFactory 来动态生成测试套件和测试用例。我还有自己的 TestLauncher 来从控制台启动我的测试。
一切看起来都不错,但我在做任何断言时都遇到问题。例如,如果我在检查变量是否为 null 时尝试执行 Assert.Fail,则我的控制台程序会立即中断,并显示如下内容:
at Gallio.Framework.Assertions.AssertionContext.Scope.ThrowFailureAccordingToBehavior(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionContext.Scope.SubmitFailure(AssertionFailure failure, Boolean noThrow)
at Gallio.Framework.Assertions.AssertionContext.Scope.SubmitFailure(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionContext.SubmitFailure(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionHelper.Fail(AssertionFailure failure)
at MbUnit.Framework.Assert.Fail(String messageFormat, Object[] messageArgs)
at Dundas.Dashboard.TestSystem.TestPrograms.DashboardImageCompare.<>c__DisplayClass6.<CreateTestSuiteByDataStore>b__1() in C:\...\test.cs:line 115
at MbUnit.Framework.TestCase.OnExecuteSelf()
at MbUnit.Framework.TestDefinition.<>c__DisplayClass9.<RunDynamicTest>b__8()
at Gallio.Common.Concurrency.ThreadAbortScope.Run(Action action)
at Gallio.Framework.Sandbox.Run(MarkupDocumentWriter markupDocumentWriter, Action action, String description)
Gallio 不应该为我捕获与断言相关的所有异常吗?我应该如何解决这个问题?
I am trying to use DynamicTestFactory in MbUnit to generate test suites and test cases on the fly. I also have my own TestLauncher to launch my test from console.
Everything seems good but I am having a problem doing any kind of assertion. For example, if I try to do Assert.Fail when I check that a variable is null, my console program breaks at that point immediately with something like the following:
at Gallio.Framework.Assertions.AssertionContext.Scope.ThrowFailureAccordingToBehavior(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionContext.Scope.SubmitFailure(AssertionFailure failure, Boolean noThrow)
at Gallio.Framework.Assertions.AssertionContext.Scope.SubmitFailure(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionContext.SubmitFailure(AssertionFailure failure)
at Gallio.Framework.Assertions.AssertionHelper.Fail(AssertionFailure failure)
at MbUnit.Framework.Assert.Fail(String messageFormat, Object[] messageArgs)
at Dundas.Dashboard.TestSystem.TestPrograms.DashboardImageCompare.<>c__DisplayClass6.<CreateTestSuiteByDataStore>b__1() in C:\...\test.cs:line 115
at MbUnit.Framework.TestCase.OnExecuteSelf()
at MbUnit.Framework.TestDefinition.<>c__DisplayClass9.<RunDynamicTest>b__8()
at Gallio.Common.Concurrency.ThreadAbortScope.Run(Action action)
at Gallio.Framework.Sandbox.Run(MarkupDocumentWriter markupDocumentWriter, Action action, String description)
Shouldn't Gallio capture all the exceptions which are related to assertions for me? How should I go around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我当时就傻了。这只是因为我正在调试模式下运行。如果我切换到发布(或使用反射调用该方法),它不会像以前那样在断言失败时中断。
I was being dumb. It's just because I am running in debug mode. If I switch to release (or invoke the method using reflection), it won't break at failed assertion like before.