Skip to content

Commit aee5ace

Browse files
committed
docs: tweaks to wording
1 parent fdc519e commit aee5ace

8 files changed

Lines changed: 46 additions & 50 deletions

File tree

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/egil/bunit/CI?logo=github&style=flat-square)](https://github.com/egil/bunit/actions?query=workflow%3ACI)
1+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/egil/bunit/RELEASE?logo=github&style=flat-square)](https://github.com/egil/bunit/actions?query=workflow%3ARELEASE)
22
[![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/egil/bunit?include_prereleases&logo=github&style=flat-square)](https://github.com/egil/bunit/releases)
33
[![Nuget](https://img.shields.io/nuget/dt/bunit?logo=nuget&style=flat-square)](https://www.nuget.org/packages/bunit/)
44
[![Issues Open](https://img.shields.io/github/issues/egil/bunit.svg?style=flat-square&logo=github)](https://github.com/egil/bunit/issues)
55
[![Gitter](https://img.shields.io/gitter/room/egil/bunit?logo=gitter&style=flat-square)](https://gitter.im/egil/bunit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
66

77
# bUnit - a testing library for Blazor components
88

9-
**bUnit** is a testing library for Blazor Components. You can:
9+
**bUnit** is a testing library for Blazor Components. Its goal is to make it easy to write _comprehensive, stable unit tests_. You can:
1010

1111
- Setup and define components under tests in C# or Razor syntax
12-
- Verify outcome using semantic HTML diffing/comparison logic
12+
- Verify outcome using semantic HTML comparer
1313
- Interact with and inspect components
1414
- Trigger event handlers
1515
- Provide cascading values
1616
- Inject services
1717
- Mock `IJsRuntime`
1818
- Perform snapshot testing
1919

20-
The library builds on top of existing unit testing frameworks such as xUnit, which runs the Blazor components tests, just as any normal unit test.
21-
22-
The library's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components.
20+
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, and MSTest, which runs the Blazor components tests, just as any normal unit test.
2321

2422
**Go to [bUnit.egilhansen.com](https://bunit.egilhansen.com) to learn more.**
2523

@@ -41,8 +39,8 @@ To get started, head to the documentation on [bUnit.egilhansen.com/docs](https:/
4139

4240
These are the current goals that should be reached before v1.0.0 is ready:
4341

44-
- **Stabilize the APIs**, such that they work equally well with both xUnit, Nunit, and MSTest as the underlying test framework. The general goals is to make it easy and obvious for developers to create the tests they needed, and fall into the pit of success.
45-
- **Get the Razor-based testing to stable**, e.g. make the discovery and running of tests defined in .razor files stable and efficient. This includes adding support for Nunit and MSTest as test runners.
42+
- **Stabilize the APIs**, such that they work equally well with both xUnit, NUnit, and MSTest as the underlying test framework. The general goals is to make it easy and obvious for developers to create the tests they needed, and fall into the pit of success.
43+
- **Get the Razor-based testing to stable**, e.g. make the discovery and running of tests defined in .razor files stable and efficient. This includes adding support for NUnit and MSTest as test runners.
4644
- **Improve the documentation**. Currently there are a list of "How to" guides planned in the [Update Docs](https://github.com/egil/bunit/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22updated+docs%22) milestone.
4745
- **Join the .NET Foundation.**. This project is too large for one person to be the owner and be the sole maintainer of, so the plan is to apply for membership as soon as possible, most likely close to or after v1.0.0 ships, and get the needed support and guidance to ensure the project long term.
4846

docs/docs/getting-started/create-test-project.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ title: Creating a new bUnit Test Project
55

66
# Creating a new bUnit Test Project
77

8-
Before you can write any tests, you need a place to put them - a test project. bUnit is not a unit test runner, so you need a general-purpose test framework, like xUnit, NUnit, or MSTest, in addition to bUnit, to run your tests, and write your assertions.
8+
To write tests, you need a place to put them - a test project. bUnit is not a unit test runner, so a general-purpose test framework, like xUnit, NUnit, or MSTest, is needed, in addition to bUnit, to write and run tests.
99

10-
If you prefer xUnit, you can use the bUnit project template approached described in the [Create a test project with bUnit template](#create-a-test-project-with-bunit-template) section further down the page. If you want to use another general-purpose testing framework, read the following section.
10+
To use bUnit with xUnit, the easiest approached is using the bUnit project template described in the [Create a test project with bUnit template](#create-a-test-project-with-bunit-template) section further down the page. To create a test project manually in a general-purpose testing frameworks agnostic way, read the following section.
1111

1212
## Create a Test Project Manually
1313

14-
To create a project for testing you Blazor components that uses either of three general purpose test frameworks, you need to go through these steps:
14+
To create a project for testing you Blazor components that uses either of three general purpose test frameworks, go through these steps:
1515

1616
1. Create a new xUnit/NUnit/MSTest testing project
1717
2. Add bUnit to the test project
1818
3. Configure project settings
19-
4. Add the test project to your solution
19+
4. Add the test project to your existing solution
2020

2121
These steps look like this from the `dotnet` CLI:
2222

2323
**1. Create a new test project**
2424

25-
Use the following command (_click on the tab that for the test framework you would like to use_):
25+
Use the following command (_click on the tab that for the test framework of choice_):
2626

2727
# [xUnit](#tab/xunit)
2828

@@ -48,7 +48,7 @@ where `-o <NAME OF PROJECT>` is used to name the test project.
4848

4949
**2. Add bUnit to the test project**
5050

51-
To add bUnit to your test project, first change to the newly created test projects folder, and then use the following command:
51+
To add bUnit to the test project, change to the newly created test projects folder and then use the following command:
5252

5353
# [xUnit](#tab/xunit)
5454

@@ -76,7 +76,11 @@ dotnet add package bunit.web --version #{VERSION}#
7676

7777
**3. Configure project settings**
7878

79-
Then you need to change a few project settings, in particular we need to change the project's SDK to `Microsoft.NET.Sdk.Razor`, remember to set `RazorLangVersion` to `3.0`, and set the `<TargetFramework>` to `netcoreapp3.1`, since bUnit builds on `.netstandard 2.1`.
79+
The test projects setting needs to be set accordingly:
80+
81+
- the project's SDK to `Microsoft.NET.Sdk.Razor`
82+
- set `RazorLangVersion` to `3.0`
83+
- set the `<TargetFramework>` to `netcoreapp3.1` (bUnit builds on `.netstandard 2.1`)
8084

8185
To do so, change the first part of the test projects `.csproj` file to look like this.:
8286

@@ -95,7 +99,7 @@ To do so, change the first part of the test projects `.csproj` file to look like
9599

96100
**4. Add the test project to your solution**
97101

98-
Then you need to add your test project to your solution (`.sln`) and add a reference between your test project and component project:
102+
If using Visual Studio, add the test project to your solution (`.sln`), and add a reference between the test project and project containing the components that should be tested:
99103

100104
```dotnetcli
101105
dotnet sln <NAME OF PROJECT>.sln add <NAME OF TEST PROJECT>
@@ -104,7 +108,6 @@ dotnet add <NAME OF COMPONENT PROJECT>.csproj reference <NAME OF TEST PROJECT>.c
104108

105109
The result should be a test project with a `.csproj` that looks like this (other packages than bUnit might have different version numbers):
106110

107-
108111
# [xUnit](#tab/xunit)
109112

110113
```xml
@@ -185,15 +188,14 @@ The result should be a test project with a `.csproj` that looks like this (other
185188

186189
## Create a Test Project with bUnit Template
187190

188-
If you want to skip a few steps in the guide above, you can use the [bUnit test project template](https://www.nuget.org/packages/bunit.template/). The bUnit project template is only available for using with xUnit as the general-purpose testing framework, but that will change in the future.
191+
To skip a few steps in the guide above, use the [bUnit test project template](https://www.nuget.org/packages/bunit.template/). The bUnit project template is only available for using with xUnit as the general-purpose testing framework, but that will change in the future.
189192

190193
The steps are as follows:
191194

192195
1. Install the template (only needed the first time)
193196
2. Create a new test project
194197
3. Add the test project to your solution
195198

196-
197199
These steps look like this from the `dotnet` CLI:
198200

199201
**1. Install the template**
@@ -216,7 +218,7 @@ where `-o <NAME OF PROJECT>` is used to name the test project.
216218

217219
**3. Add the test project to your solution**
218220

219-
Then you need to add your test project to your solution (`.sln`) and add a reference between your test project and component project:
221+
If using Visual Studio, add the test project to your solution (`.sln`), and add a reference between the test project and project containing the components that should be tested:
220222

221223
```dotnetcli
222224
dotnet sln <NAME OF PROJECT>.sln add <NAME OF TEST PROJECT>
@@ -225,6 +227,6 @@ dotnet add <NAME OF COMPONENT PROJECT>.csproj reference <NAME OF TEST PROJECT>.c
225227

226228
## Further Reading
227229

228-
Now you are ready to write some tests. To learn how, continue reading the <xref:writing-csharp-tests> and <xref:writing-razor-tests> pages.
230+
To start creating tests, continue reading the <xref:writing-csharp-tests> and <xref:writing-razor-tests> pages.
229231

230-
For addition tips and tricks that will make writing tests easier, see the <xref:misc-test-tips> page.
232+
For addition tips and tricks that will make writing tests easier, see the <xref:misc-test-tips> page.

docs/docs/getting-started/fixture-details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The test looks like this:
9999

100100
[!code-html[SimpleTodoTest.razor](../../samples/tests/razor/SimpleTodoTest.razor?highlight=4,5,8-10,13,20,29,30,35-37,44)]
101101

102-
Let's look at whats going on in this test:
102+
Let's look at what's going on in this test:
103103

104104
1. The fixture has both a setup and test method specified. The setup methods is used to register an empty list of tasks, that the `<SimpleTodo>` component requires.
105105
2. The `<SimpleTodo>` component is wrapped in a `<CascadingValue>` component that passes down the "Theme" cascading value.

docs/docs/getting-started/index.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,20 @@ title: Getting Started with bUnit
55

66
# Getting Started with bUnit
77

8-
To get started writing tests for your Blazor components, you first need to set up a test project. Then you can start writing your tests, using either C# or Razor syntax.
8+
To start writing tests for Blazor components, first set up a test project, then you can start writing tests, either using C# or Razor syntax.
99

10-
These three pages will teach you *the basics*:
10+
The *the basics* topics are:
1111

1212
1. **<xref:create-test-project>** covers setting up a bUnit test project.
13-
2. **<xref:writing-csharp-tests>** covers the basics of writing tests in C#.
14-
With C# based tests, you write all your testing logic in C# files, i.e. like regular unit tests.
15-
3. **<xref:writing-razor-tests>** covers the basics of writing tests in Razor and C# syntax.
16-
With Razor based tests, you write tests in `.razor` files, which allows you to declare, in Razor syntax, the component under test and other markup fragments you need. You still write your assertions via C# in the .razor file, inside `@code {...}` blocks.
13+
2. **<xref:writing-csharp-tests>** covers the basics of writing tests in C#, i.e. like regular unit tests.
14+
3. **<xref:writing-razor-tests>** covers the basics of writing tests in `.razor` files in Razor and C# syntax.
1715

18-
After reading those, these topics will take you to the *next level*:
16+
The *next level* topics:
1917

20-
1. **[Providing different types of input](xref:providing-input)** to a component under test, e.g. passing parameters or injecting services.
18+
1. **[Providing different types of input](xref:providing-input)** to a component under test in C# based tests, e.g. passing parameters or injecting services.
2119
2. **[Verifying output in various ways](xref:verification)** from a component under test, e.g. inspecting the rendered markup.
2220
3. **[Mocking dependencies](xref:mocking)** a component under test has, e.g. the `IJsRuntime` or `HttpClient`.
2321

24-
## Examples
25-
26-
To see examples of how to work assert and manipulate a rendered component, go to the following pages:
27-
28-
- [C# test examples in the sample project](https://github.com/egil/bunit/tree/master/sample/tests/Tests)
29-
- [Razor based test examples in the sample project](https://github.com/egil/bunit/tree/master/sample/tests/RazorTestComponents)
30-
- [Snapshot test examples in the sample project](https://github.com/egil/bunit/tree/master/sample/tests/SnapshotTests)
22+
## Getting Help
3123

24+
Cannot figure out how to write a test for a testing scenario? Found a testing scenario that is hard or inelegant with bUnit? Found a bug in bUnit? Head over to the [GitHub issues list](https://github.com/egil/bunit/issues) and ask a question, suggest a new feature, or join [bUnits Gitter channel](https://gitter.im/egil/bunit) and let us know. There are no stupid questions, and all questions are welcome!

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ title: Writing Tests in C# for Blazor Components
77

88
Testing Blazor components is a different from testing regular C# classes: Blazor components are *rendered*, they have the *Blazor component life cycle*, during which we can *provide input* to them and where they *produce output*.
99

10-
**bUnit** enables you to render the component you want to test, pass in parameters to it, inject services into it, and access the rendered component instance and the markup it has produced.
10+
Use **bUnit** to render the component you want to test, pass in parameters to it, inject services into it, and access the rendered component instance and the markup it has produced.
1111

1212
Rendering a component happens through bUnit's <xref:Bunit.TestContext>, and the result of the rendering, a <xref:Bunit.IRenderedComponent`1>, provides access to the component instance, and the markup produced by the component.
1313

1414
## Creating a Basic Test
1515

16-
Let us see a simple example, where we test the following `<HelloWorld>` component:
16+
This is a simple example, that tests the following `<HelloWorld>` component:
1717

1818
[!code-html[HelloWorld.razor](../../samples/components/HelloWorld.razor)]
1919

@@ -38,7 +38,7 @@ Let us see a simple example, where we test the following `<HelloWorld>` componen
3838
3939
***
4040

41-
In this test, we do the following:
41+
The following happens in the test above:
4242

4343
1. New up the disposable <xref:Bunit.TestContext>, and assign it using the `using var` syntax, to avoid unnecessary indention.
4444
2. Render the `<HelloWorld>` component using <xref:Bunit.TestContext>, which we do through the <xref:Bunit.TestContext.RenderComponent``1(Bunit.Rendering.ComponentParameter[])> method. We will cover passing parameters to components elsewhere.

docs/docs/interaction/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ uid: interaction
33
title: Interacting with a Component Under Test
44
---
55

6-
# Interacting with a Component Under Test
6+
# Interacting with a Component Under Test
7+

docs/docs/providing-input/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ title: Providing Input to a Component Under Test
55

66
# Providing Input to a Component Under Test
77

8-
providing a toc with descriptions of each topic
8+
This section covers the various ways to provide input to a component under test, its split into three sub sections:
9+
10+
- **<xref:passing-parameters-to-components>:** This covers passing regular parameters, child content, cascading values, event callbacks, etc. This topic is mostly relevant when writing tests in C# only.
11+
- **<xref:inject-services-into-components>:** This covers injecting services into components under test. This topic is relevant for both Razor-based tests and C# only tests.
12+
- **<xref:configure-3rd-party-libs>:** This covers setting up 3rd party libraries in a bUnit testing scenario, such that components under test that use them can be tested easily.

docs/index.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ title: bUnit - a testing library for Blazor components
1111

1212
# bUnit - a testing library for Blazor components
1313

14-
**bUnit** is a testing library for Blazor Components. You can:
14+
**bUnit** is a testing library for Blazor Components. Its goal is to make it easy to write _comprehensive, stable unit tests_. You can:
1515

1616
- Setup and define components under tests in C# or Razor syntax
17-
- Verify outcome using semantic HTML diffing/comparison logic
17+
- Verify outcome using semantic HTML comparer
1818
- Interact with and inspect components
1919
- Trigger event handlers
2020
- Provide cascading values
2121
- Inject services
2222
- Mock `IJsRuntime`
2323
- Perform snapshot testing
2424

25-
The library builds on top of existing unit testing frameworks such as xUnit, which runs the Blazor components tests, just as any normal unit test.
26-
27-
The library's goal is to make it easy to write _comprehensive, stable unit tests_ for Blazor Components/Razor Components.
25+
bUnit builds on top of existing unit testing frameworks such as xUnit, NUnit, and MSTest, which runs the Blazor components tests, just as any normal unit test.
2826

2927
**Go to the [Documentation](xref:getting-started) pages to learn more.**
3028

@@ -58,8 +56,8 @@ bUnit is available on NuGet in various incarnations. If you are using xUnit as y
5856

5957
These are the current goals that should be reached before v1.0.0 is ready:
6058

61-
- **Stabilize the APIs**, such that they work equally well with both xUnit, Nunit, and MSTest as the underlying test framework. The general goals is to make it easy and obvious for developers to create the tests they needed, and fall into the pit of success.
62-
- **Get the Razor-based testing to stable**, e.g. make the discovery and running of tests defined in .razor files stable and efficient. This includes adding support for Nunit and MSTest as test runners.
59+
- **Stabilize the APIs**, such that they work equally well with both xUnit, NUnit, and MSTest as the underlying test framework. The general goals is to make it easy and obvious for developers to create the tests they needed, and fall into the pit of success.
60+
- **Get the Razor-based testing to stable**, e.g. make the discovery and running of tests defined in .razor files stable and efficient. This includes adding support for NUnit and MSTest as test runners.
6361
- **Improve the documentation**. Currently there are a list of "How to" guides planned in the [Update Docs](https://github.com/egil/bunit/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22updated+docs%22) milestone.
6462
- **Join the .NET Foundation.**. This project is too large for one person to be the owner and be the sole maintainer of, so the plan is to apply for membership as soon as possible, most likely close to or after v1.0.0 ships, and get the needed support and guidance to ensure the project long term.
6563

0 commit comments

Comments
 (0)