Analyzer to detect not awaited async calls in a test case
- Dominant language
- C#
- Stars
- 1k
- Forks
- 312
- Avg merge
- 8h 30m
- Merged PRs (30d)
- 469
Description
## Summary
Signal an async call is not awaited
```csharp
[TestMethod]
public void AsyncThrow()
{
Assert.ThrowsAsync(async () =>
{
throw new ArgumentException("exception", "value");
});
}
```
Expected analyzer behavior: suggest
```csharp
[TestMethod]
public async Task AsyncThrow()
{
await Assert.ThrowsAsync(async () =>
{
throw new ArgumentException("exception", "value");
});
}
```
Currently https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0040 covers only `async void` case.
Contributor guide
Research direction
Start with the existing MSTEST0040 analyzer and its documentation, then compare its async-void handling with the not-awaited Assert.ThrowsAsync example in this issue. Add coverage for the shown synchronous test pattern and verify that the analyzer suggests an async test method with await while preserving the existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100