You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updates doc to explain how to enable .razor files with TUnit
Explains that TUnit only works with Razor files in reflection
mode due to source generator limitations.
Provides instructions for setting up TUnit with .razor files
using a .runsettings file and updating the .csproj.
Adds a note recommending a separate test project for bUnit tests
to avoid performance issues.
The test projects setting needs to be set to the following:
149
149
150
-
- the project's SDK needs to be set to `Microsoft.NET.Sdk.Razor` (this does not work with **TUnit** - a more detailed explanation can be found below)
150
+
- the project's SDK needs to be set to `Microsoft.NET.Sdk.Razor` (for **TUnit** this only works in reflection mode - a more detailed explanation can be found below)
151
151
- set the `<TargetFramework>` to `net8.0`
152
152
153
153
> [!NOTE]
@@ -313,7 +313,39 @@ The result should be a test project with a `.csproj` that looks like this (non b
313
313
```
314
314
315
315
> [!WARNING]
316
-
> **TUnit** and the `Microsoft.NET.Sdk.Razor` both utilize source code generators. Source generators can not see or interact with the output of another generator. Therefore **TUnit** does not work with `razor` files. Using `cs` based tests is working perfectly fine. For more information regarding the setup of **TUnit** head over to: https://github.com/thomhurst/TUnit
316
+
> **TUnit** and the `Microsoft.NET.Sdk.Razor` SDK both utilize source code generators. Source generators cannot see or interact with the output of another generator. Therefore **TUnit** only works with `.razor` files in **reflection mode**. However `.cs`-based tests work as expected in the default mode. For more information regarding the setup of **TUnit** head over to: https://github.com/thomhurst/TUnit
317
+
318
+
To set up TUnit for use with `.razor` files, the `TUNIT_EXECUTION_MODE` environment variable must be set to `reflection` so that the TUnit test runner can discover these tests.
319
+
320
+
A straightforward way to configure this is by creating a `.runsettings` file in the test project and referencing it from the `.csproj`.
With this setup, all bUnit `.razor` tests are discovered and run consistently in Visual Studio and other supported environments.
344
+
345
+
> [!NOTE]
346
+
> Running in reflection mode is slower than the default execution mode. It is therefore recommended to keep bUnit tests in a separate test project, so they don’t affect the performance of other test runs.
347
+
348
+
For more information on reflection mode, see: https://tunit.dev/docs/execution/engine-modes/.
0 commit comments