TemplateVerifier CLI tests fail with xUnit v3: TestContext.TestMethod is null
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
The `VerifyCommandFullDevLoop` and `VerifyCommandFullDevLoopWithNotInstalledTemplate` tests in
`Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests` fail when run in Helix because the
CLI tool subprocess calls `Verifier.VerifyDirectory()` from `Verify.XunitV3` outside of an
xUnit test context.
**Root cause**: `Microsoft.TemplateEngine.Authoring.TemplateVerifier` (a shipping library)
references `Verify.XunitV3`, which requires `TestContext.Current.TestMethod` at runtime.
This worked with xUnit v2's `Verify.Xunit` (which used compile-time `[CallerFilePath]`),
but xUnit v3 switched to runtime test context. When the CLI tool runs the TemplateVerifier
in a subprocess, there's no xUnit test runner, so `TestContext.TestMethod` is null → exit
code 70 instead of the expected 65.
**Fix needed**: Refactor `Microsoft.TemplateEngine.Authoring.TemplateVerifier` to not depend
on `Verify.XunitV3`. The library should use the base `Verify` API. This also requires
refactoring the shared `CommandUtils` code which uses `ITestOutputHelper` from xUnit.
**Affected tests**:
- `VerifyCommandTests.VerifyCommandFullDevLoop`
- `VerifyCommandTests.VerifyCommandFullDevLoopWithNotInstalledTemplate`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.