Docs should be updated to address how to use TAEF for the development of unit tests #2762

Closed
opened 2026-01-30 23:04:26 +00:00 by claunia · 3 comments
Owner

Originally created by @german-one on GitHub (Jul 14, 2019).

In #1850 I was ask to add a test file to the unit tests.
First hurdle was that WEX, which I found in the existing source files, is related to TAEF. Without knowing that, you are out of luck to find anything in the docs.
We have TAEF.md in the doc folder but it tells nothing about how to use it for the development of unit tests and the link to the official documentation is broken (of course I was able to find it anyway).
I was tearing my hair out when I tried to figure out why WexTestClass.h was not found even if it was included in the existing source files. Whenever I see a quoted file name like in #include "WexTestClass.h" I automatically assume that this file will be found in the project directory. But this is neither the case nor required, which should be mentioned.
The official documentation already states that the WDK has to be installed as well as the Spectre mitigated libraries. Nevertheless I think it would be worth to leave some words and links about the preconditions in the docs here.

Originally created by @german-one on GitHub (Jul 14, 2019). <!-- Briefly describe which document needs to be corrected and why. --> In #1850 I was ask to add a test file to the unit tests. First hurdle was that `WEX`, which I found in the existing source files, is related to `TAEF`. Without knowing that, you are out of luck to find anything in the docs. We have TAEF.md in the doc folder but it tells nothing about how to use it for the development of unit tests and the link to the official documentation is broken (of course I was able to find it anyway). I was tearing my hair out when I tried to figure out why `WexTestClass.h` was not found even if it was included in the existing source files. Whenever I see a quoted file name like in `#include "WexTestClass.h"` I automatically assume that this file will be found in the project directory. But this is neither the case nor required, which should be mentioned. The official documentation already states that the WDK has to be installed as well as the Spectre mitigated libraries. Nevertheless I think it would be worth to leave some words and links about the preconditions in the docs here.
Author
Owner

@german-one commented on GitHub (Jul 15, 2019):

First attempt (as long as I remember the pitfalls) ...



Adding test code to a Unit Test

Updates in the code base may require proper testing and validating of the code. Therefore each project should already have a Unit Test in a ut_... folder. Contributors might be asked to add a source file with test code to the related Unit Test project. The code shall consist of a single class with test methods, following the Test Authoring and Execution Framework (TAEF).

If you have to add a new file to a Unit Test project then check the following preconditions first.

  • Install the Windows Driver Kit (WDK). Follow at least steps 1 and 2. Even if you already installed Visual Studio, don't forget the Spectre mitigated libraries as mentioned at the end of step 1.

If writing the test code

  • Carefully read section Authoring Tests in C++. The quoted header name in #include "WexTestClass.h" might be confusing. You are not required to copy TAEF headers into the project folder.
  • Use the TAEF Verify Macros for C++ in your test code to indicate whether a verification succeeded.

Before pushing the commit with the test code make sure it behaves as expected

  • Compile it.
  • Perform the test
    • using te.exe (see TAEF.md).
    • alternatively run razzle.cmd and runut.cmd from within a CMD shell. You will find them in the tools\ directory.


... even though I have my doubts that I would be the right person to write a documentation like that. It should be done by a native speaker to avoid bad or ambiguous wording. And it should be written by a core contributor because they know best what they require.

@german-one commented on GitHub (Jul 15, 2019): First attempt (as long as I remember the pitfalls) ... --- --- ### Adding test code to a Unit Test ### Updates in the code base may require proper testing and validating of the code. Therefore each project should already have a Unit Test in a `ut_...` folder. Contributors might be asked to add a source file with test code to the related Unit Test project. The code shall consist of a single class with test methods, following the [Test Authoring and Execution Framework (TAEF)](https://docs.microsoft.com/en-us/windows-hardware/drivers/taef/). If you have to add a new file to a Unit Test project then check the following preconditions first. - Install the [Windows Driver Kit (WDK)](https://docs.microsoft.com/de-de/windows-hardware/drivers/download-the-wdk). Follow at least steps 1 and 2. Even if you already installed Visual Studio, don't forget the Spectre mitigated libraries as mentioned at the end of step 1. If writing the test code - Carefully read section [Authoring Tests in C++](https://docs.microsoft.com/en-us/windows-hardware/drivers/taef/authoring-tests-in-c--). The quoted header name in `#include "WexTestClass.h"` might be confusing. You are **not** required to copy TAEF headers into the project folder. - Use the [TAEF Verify Macros for C++](https://docs.microsoft.com/en-us/windows-hardware/drivers/taef/verify) in your test code to indicate whether a verification succeeded. Before pushing the commit with the test code make sure it behaves as expected - Compile it. - Perform the test - using `te.exe` (see [TAEF.md](https://github.com/microsoft/terminal/blob/master/doc/TAEF.md)). - alternatively run `razzle.cmd` and `runut.cmd` from within a CMD shell. You will find them in the `tools\` directory. --- --- ... even though I have my doubts that I would be the right person to write a documentation like that. It should be done by a native speaker to avoid bad or ambiguous wording. And it should be written by a core contributor because they know best what they require.
Author
Owner

@zadjii-msft commented on GitHub (Jul 15, 2019):

I actually don't think you need the WDK anymore. We're using taef as part of a nuget package. For example, src\cascadia\UnitTests_TerminalCore\UnitTests.vcxproj is the unittest project for the TerminalCore. It includes the Taef.Redist.Wlk.* package, which handles installing TAEF for you.

@zadjii-msft commented on GitHub (Jul 15, 2019): I actually don't think you need the WDK anymore. We're using taef as part of a nuget package. For example, `src\cascadia\UnitTests_TerminalCore\UnitTests.vcxproj` is the unittest project for the TerminalCore. It includes the `Taef.Redist.Wlk.*` package, which handles installing TAEF for you.
Author
Owner

@german-one commented on GitHub (Jul 15, 2019):

I actually don't think you need the WDK anymore.

I must have done something wrong in this case. UnitTests.vcxproj doesn't open via double click (I get an error that it doesn't contain any configuration). So, my first attempt was to just open existing source files (UtilsTest.cpp and UuidTests.cpp) from within CascadiaPackage. Before I installed the WDK, I immediately got the error that WexTestClass.h was not found. After installing the WDK and Spectre mitigated libraries, everything was working as expected.

@german-one commented on GitHub (Jul 15, 2019): > I actually don't think you need the WDK anymore. I must have done something wrong in this case. `UnitTests.vcxproj` doesn't open via double click (I get an error that it doesn't contain any configuration). So, my first attempt was to just open existing source files (`UtilsTest.cpp` and `UuidTests.cpp`) from within `CascadiaPackage`. Before I installed the WDK, I immediately got the error that `WexTestClass.h` was not found. After installing the WDK and Spectre mitigated libraries, everything was working as expected.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2762