Automated Testing OpenXML SDK

前端 未结 4 360
無奈伤痛
無奈伤痛 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:44

    The high-level approach for testing Microsoft Word document generation is the following:

    1. Define test cases, where each one consists of:

      • the generator inputs, i.e., the data to be used in generating Word documents; and
      • the expected output in Open XML format, i.e., the Open XML markup representing a correctly generated Word document.
    2. Write test methods, using your favorite unit testing framework (e.g., xUnit). Using the typical "Arrange, Act, Assert" pattern, those test methods:

      • set up the generator, generator inputs, and expected generator outputs as required;
      • run the generator, providing the generator inputs and capturing the actual generator outputs; and
      • compare the actual generator outputs with the expected generator outputs.

    It is very easy to retrieve the actual generator output with the Open XML SDK. When comparing actual and expected outputs, you can apply different levels of markup filtering or simplification. For example, you could focus on the essential markup such as the content controls (w:sdt elements) mentioned in the question.

提交回复
热议问题