Skip to content

Commit 5add684

Browse files
committed
Added warning to docs about using TextContext.
1 parent 6e0620d commit 5add684

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/site/docs/getting-started/writing-csharp-tests.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ Then methods like <xref:Bunit.TestContext.RenderComponent``1(Bunit.Rendering.Com
8282

8383
***
8484

85+
> [!IMPORTANT]
86+
> All the examples in the documentation explicitly new up a `TestContext`, i.e. `using var ctx = new TestContext()`. If you are using the trick above and have your test class inherit from `TestContext`, you should **NOT** new up a `TestContext` in test methods also.
87+
>
88+
> Simply call the test contest's methods directly, as they are available in your test class.
89+
>
90+
> For example, `var cut = ctx.RenderComponent<HelloWorld>();`
91+
> becomes `var cut = RenderComponent<HelloWorld>();`.
92+
8593
## Further Reading
8694

8795
With the basics out of the way, next we will look at how to pass parameters and inject services into our component under test. After that, we will cover ways we can verify the outcome of a rendering in more detail

0 commit comments

Comments
 (0)