开发者

Gallio DynamicTestFactory and assertion

开发者 https://www.devze.com 2023-03-31 19:02 出处:网络
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.

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.SubmitFai开发者_开发技巧lure(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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消