Automated Testing OpenXML SDK

前端 未结 4 486
無奈伤痛
無奈伤痛 2021-01-02 06:40

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 auto

4条回答
  •  心在旅途
    2021-01-02 07:19

    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) [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) 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) Create a concrete implementation of your interface, which forwards calls to the OpenXML SDK

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

    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.

提交回复
热议问题