Skip to content

Commit 85e6bc0

Browse files
committed
feat: WaitForAssertion method marked as an assertion method
1 parent 045fcd0 commit 85e6bc0

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- `WaitForAssertion` method is now marked as an assertion method with the `[AssertionMethod]` attribute. This makes certain analyzers like SonarSource's [Tests should include assertions](https://rules.sonarsource.com/csharp/RSPEC-2699) happy. By [@egil](https://github.com/egil).
12+
913
### Fixes
1014

1115
- A race condition existed between `WaitForState` / `WaitForAssertion` and `FindComponents`, if the first used the latter. Reported by [@rmihael](https://github.com/rmihael), [@SviatoslavK](https://github.com/SviatoslavK), and [@RaphaelMarcouxCTRL](https://github.com/RaphaelMarcouxCTRL). Fixed by [@egil](https://github.com/egil) and [@linkdotnet](https://github.com/linkdotnet).

src/bunit.core/Extensions/WaitForHelpers/RenderedFragmentWaitForHelperExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.ExceptionServices;
2+
using Bunit.Asserting;
23
using Bunit.Extensions.WaitForHelpers;
34

45
namespace Bunit;
@@ -50,6 +51,7 @@ public static void WaitForState(this IRenderedFragmentBase renderedFragment, Fun
5051
/// <param name="assertion">The verification or assertion to perform.</param>
5152
/// <param name="timeout">The maximum time to attempt the verification.</param>
5253
/// <exception cref="WaitForFailedException">Thrown if the timeout has been reached. See the inner exception to see the captured assertion exception.</exception>
54+
[AssertionMethod]
5355
public static void WaitForAssertion(this IRenderedFragmentBase renderedFragment, Action assertion, TimeSpan? timeout = null)
5456
{
5557
using var waiter = new WaitForAssertionHelper(renderedFragment, assertion, timeout);

0 commit comments

Comments
 (0)