bUnit bUnit

    Show / Hide Table of Contents

    Getting Started with bUnit

    To start writing tests for Blazor components, first set up a test project and then you can start adding tests using either C# or Razor syntax.

    The basic getting started topics are as follows:

    1. Creating a new bUnit Test Project covers setting up a bUnit test project.
    2. Writing Tests in C# for Blazor Components covers the basics of writing tests in C#, i.e. regular unit tests.
    3. Writing Tests in Razor Syntax for Blazor Components covers the basics of writing tests in .razor files using Razor and C# syntax.

    The next level topics are:

    1. Providing different types of input to a component under test in C# based tests, e.g. passing parameters or injecting services.
    2. Verifying output in various ways from a component under test, e.g. inspecting the rendered markup.
    3. Mocking dependencies a component under test has, e.g. the IJsRuntime or HttpClient.

    Getting Help

    Can't figure out how to write a test for a testing scenario? Do you have a testing scenario that is hard to write or cannot be written elegantly with bUnit? Have you found a bug in bUnit? Head over to bUnit’s discussion forum to ask a question, give feedback, or suggest a new feature. Alternatively, join bUnits Gitter channel and let us know. There are no stupid questions - all are welcome!

    Editorial support provided by Packt.

    • Improve this Doc
    Back to top Documentation updated on 1/20/2021 6:00:54 PM +00:00 in commit b61b4ab737.