自动化测试OpenXML SDK [英] Automated Testing OpenXML SDK

查看:50
本文介绍了自动化测试OpenXML SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用内容控件和OpenXML SDK来实现ms word文档的生成.我想对该代码进行一些自动化测试(单元测试或一些简单的UI自动化测试).

I'm implementing ms word document generation using content controls and OpenXML SDK. I'd like to have some automated testing for that code (unit tests or some easy UI automation tests).

任何人都具有测试MS Word文档生成的经验吗?有哪些可能的选择?

Does anyone has expericnce with testing MS Word document generation? What are the possible options?

提前谢谢!

推荐答案

不,我还没有完成MS Word文档生成的单元测试,但是正如IngóVals所说,它与任何其他形式的M单元测试.

No, I haven't done unit testing of MS Word Document generation, but as Ingó Vals says, it shouldn't be any different from any other form of unit testing.

1)[可选-确保您了解正确使用SDK的需求].确定您的应用如何驱动SDK.编写一些模拟预期功能的测试脚本,并确保它们生成的Word文档符合您的期望.

1) [Optional - to ensure that you understand correct usage of the SDK for your needs]. Work out how your app should drive the SDK. Write some test scripts that mimic intended functionality and ensure that the Word documents they generate meet your expectations.

2)创建一个或多个接口,这些接口包含与生成文档所需的功能相对应的方法.注意:该接口不需要提供OpenXML SDK的全部功能,而只需提供应用程序所需的功能即可.

2) Create an interface (or interfaces) that contain methods that correspond to the functionality that you need for your documentation generation. Note: the interface does not need to offer the full functionality of the OpenXML SDK - only the functionality that you need for your application.

3)创建接口的具体实现,该实现将调用转发到OpenXML SDK

3) Create a concrete implementation of your interface, which forwards calls to the OpenXML SDK

4)利用您在应用程序中创建的界面来执行文档生成.

4) Utilise the interface you created in your application to perform document generation.

5)使用NUnit和NMock(或类似工具)编写驱动应用程序生成层的单元测试.这些测试应使用模拟接口,而不是具体实现的实例.现在,您可以在测试中断言生成层的行为符合预期.

5) Use NUnit and NMock (or similar) to write unit tests that drive the generation layer of your application. These tests should use a mocked interface, rather than an instance of the concrete implementation. You can now assert in your tests that your generation layer behaves as you expect.

这篇关于自动化测试OpenXML SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆