Specflow Report with Async test methods issue
I have test methods something like below, if any assertion fails in async test method it terminates the complete test runner host, I am not even talking about exception here, also errors are not at all captured in livingDoc report.
[Given(….)]
public async void/Task someMethod(){
var result = await giveMeMyDataAsync(); //this runs perfectly fine
//assertion failure
Assert.IsNotNull(result) //this assertion fails and complete test runner fails
// doesn't go forward
}
to fix this I changed the code as below , I tried to wrap above code in try catch still the same affect, it is hard stopping host crashing the Nunit runner. Also It doesn't report
but the below code is fixing the issue, livignDoc captures assertion failures as desired.
[Given(….)]
public void/Task someMethod(){
var result giveMeMydataAsync().GetAwaiter().GetResult()
//assertion failure
Assert.IsNotNull(result)
}
what is the recommendation here for async test methods which can have assertion failures,
but still shouldn't cause host to terminate and still be able to capture step failures
in livingDoc report.
would the recommendation be we should not have async at all in step definitions?
0
Please sign in to leave a comment.
Comments
0 comments