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

查看:23
本文介绍了自动化测试 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 所说,它应该与任何其他形式的单元测试.

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天全站免登陆