Assert unit tests in natural language using awesome expectations.
-
Install the
aweXpectnuget packagedotnet add package aweXpect
-
Add the following
usingstatement:using aweXpect;
This brings the static
Expectclass and lots of extension methods into scope. -
See the documentation or the migration guide for more information.
By using async assertions per default, we have a consistent API and other perks:
- Complete async support, e.g.
IAsyncEnumerableHttpResponseMessageor similar async types - No need to distinguish between
action.Throws()andawait asyncAction.ThrowsAsync() - The evaluation is only triggered after the complete fluent chain is loaded, which has some nice benefits:
Becausecan be registered once as a general method that can be applied at the end of the expectation instead of cluttering all methods with thebecauseandbecauseArgsparametersWithCancellationcan also be registered at the end an applies aCancellationTokento all async methods which allows cancellation ofIAsyncEnumerableevaluations- Expectations can be combined directly (via
Expect.ThatAll) instead of relying on global state ( e.g. assertion scopes)
A focus on performance allows you to execute your tests as fast as possible.
Special care is taken for the happy case (succeeding tests) to be as performant as possible. See
the benchmarks for more details.
We added lots of extensibility points to allow you to build custom extensions.
The aweXpect.Core package is intended to be a stable source for
extensions, so that the risk of version conflicts between different extensions can be reduced.
You can extend the functionality for any types, by adding extension methods on IThat<TType>.
More information can be found in the extensibility guide.
Extension projects
-
aweXpect.Json
Expectations for the System.Text.Json namespace. -
aweXpect.Web
Expectations for HttpClient. -
aweXpect.Reflection
Expectations for reflection types. -
aweXpect.Testably
Expectations for the file and time system from Testably.Abstractions. -
aweXpect.Mockolate
Expectations to verify interactions with mocks from Mockolate.