Why are the async methods private? #552
Replies: 1 comment 2 replies
-
The short explanation is that it is fairly easy to get into a deadlock like situation, where, if you have a component that does async stuff you are awaiting, but that async stuff is triggered by you providing data to a mock from the test or triggering an event handler from the test, then you cannot proceed. The alternative pattern is described here: https://bunit.dev/docs/verification/async-assertion.html. Besides That said, you might have a corner case that I have not thought of, so I would love to get a small sample project which shows your scenario that I can investigate. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a test which calls
component.Find("form").Submit()
where subsequent assertions fail intermittently. This appears to be due to a race condition.There is a private
SubmitAsync()
extension method (whichSubmit()
calls internally, but discards the resultingTask
without waiting).Using
await component.Find("form").TriggerEventAsync("onsubmit", EventArgs.Empty);
fixes my test and is reliable. This is almost exactly howSubmitAsync()
is implemented internally.Could the async extension methods be made
public
? Or is there a good reason to keep theseprivate
, in which case should I use a different approach in my tests?Beta Was this translation helpful? Give feedback.
All reactions