【发布时间】:2012-09-25 11:45:53
【问题描述】:
我已经为以 XML 作为源和平面文件模式作为目标的地图编写了单元测试。
我可以将地图的“TestMap 输出”属性设置为 XML 或原生。然后,当我在解决方案资源管理器中右键单击地图并选择测试地图时,效果很好,我得到一个 XML 文件或平面文件,具体取决于我为“TestMap 输出”属性选择的值。在这两种情况下,所有预期的字段都使用来自输入 XML 文档的正确值进行填充。
当我使用 Microsoft.BizTalk.TestTools.Mapper.TestableMapBase 类的 TestMap 方法执行单元测试时,出现了我的问题。我收到错误“对象引用未设置为对象的实例”,这是堆栈跟踪:
at Microsoft.BizTalk.TOM.CXSDSchemaTree.CreateNativeInstance(String strXMLInstFileName, String strNativeInstanceOutputFileName, InstanceGenerationOptions options, ITOMErrorInfo[]& errInstanceCreationErrors)
at Microsoft.BizTalk.TOM.CXSDSchemaTree.CreateNativeInstanceFromXMLInstance(String strXMLInstFileName, String strNativeInstFileName, ITOMErrorInfo[]& errInstCreationErrors)
at Microsoft.BizTalk.TestTools.Mapper.TestableMapBase.TestMap(String inputInstanceFilename, InputInstanceType inputType, String outputInstanceFilename, OutputInstanceType outputType)
at x.Int.WMS.Testing.Unit.UnitTests.FromAx.UnitTest_CanonicalCustomer_2_MLS_MRE.CallMap(TestableMapBase target) in C:\Development\x.Int.WMS\Dev\V1.0\Src\Solutions\WMS\x.Int.WMS.Testing.Unit\UnitTests\FromCanonical\UnitTest_CanonicalCustomer_2_MLS_MRE.cs:line 68
at x.Int.WMS.Testing.Unit.UnitTests.FromAx.UnitTest_CanonicalCustomer_2_MLS_MRE.SetupTest() in C:\Development\x.Int.WMS\Dev\V1.0\Src\Solutions\WMS\x.Int.WMS.Testing.Unit\UnitTests\FromCanonical\UnitTest_CanonicalCustomer_2_MLS_MRE.cs:line 33
at x.Int.WMS.Testing.Unit.UnitTests.FromAx.UnitTest_CanonicalCustomer_2_MLS_MRE.RecordID_IsMapped() in C:\Development\x.Int.WMS\Dev\V1.0\Src\Solutions\WMS\x.Int.WMS.Testing.Unit\UnitTests\FromCanonical\UnitTest_CanonicalCustomer_2_MLS_MRE.cs:line 45
有什么想法吗?
【问题讨论】:
-
你能把代码贴在你的单元测试里面吗?可能有助于跟踪对象引用。
-
顺便说一句,我认为单元测试 TestMap 方法不会产生平面文件输出 - 很高兴被证明是错误的!
-
对不起这位男士,今晚才有机会再看一眼——猜猜看;现在开始工作了!我怀疑问题的原因可能是 GAC 中的旧程序集。尼克,我可以确认 TestableMapBase 对象上的 TestMap 方法可以非常愉快地生成“本机”地图输出文件。所需要的只是将 OutputInstanceType.XML 作为第四个参数传递。
标签: unit-testing maps biztalk