我有600个功能性Xunit测试,每个测试都在调用 httpclient.getAsync(apiurl)
和 httpclient.postasync(apiurl,data)它将称为一些外部API。
当我依次执行每个测试时,所有测试都可以正常工作。同样,即使我运行5-6个测试用例,也可以正常工作。
我的问题是,当我从顶部启动所有600个测试用例(将启动50个左右600个测试用例)时,所有测试都悬挂在发送 httpclient.postasync(apiurl,data)方法。
同样的问题发生在执行 httpclient.getAsync(apiurl)
方法的点。但是,在我将其更改为 httpclient.getAsync(apiurl).configureawait(false)
它解决了问题。
但是,当我更改 httpclient.postasync(apiurl,data)
httpclient.postasync(apiurl,data).configureawait(false)问题仍然相同。
有人可以解释为什么会发生这种情况以及我该怎么办来解决这个问题。
I have 600 functional xUnit tests and each of the test is calling a httpClient.GetAsync(apiUrl)
and httpClient.PostAsync(apiUrl, data)
methods in the middle of the test which will call some external APIs.
When I execute each test sequentially all working fine. Also even when I run 5 - 6 test cases parallelly then also everything works fine.
My problem is, when I start all 600 test cases from the top (which will start around 50 out 600 test cases parallelly), all the tests are hanging where it sends the httpClient.PostAsync(apiUrl, data)
method.
The same issue happened at the point where it executes the httpClient.GetAsync(apiUrl)
method. But after I change it as httpClient.GetAsync(apiUrl).ConfigureAwait(false)
it fix the issue.
But when I change the httpClient.PostAsync(apiUrl, data)
to httpClient.PostAsync(apiUrl, data).ConfigureAwait(false)
issue is still the same.
Can someone explain why this happens and what should I do to fix this issue.
发布评论
评论(1)
当我更改
httpclient.postasync(apiurl,data)
方法下面时,它将解决该问题。我不确定两种方法之间有什么区别。以前,
我在下面修改了上面的修改,并解决了问题。
我还发现以下帖子已经讨论过一些类似的问题。如果有人面临类似问题,请遵循以下帖子,因为它包含一些更有用的提示和原因。
When I change the
httpClient.PostAsync(apiUrl, data)
method as below, it fix the issue. I'm not sure what the difference between two methods.Previous way
I modified above as below and it fixed the issue.
Also I found some similar problem that has been discussed in below post. If someone facing similar issue, please follow below post as it contains some more useful tips and reasons.
HttpClient.GetAsync(...) never returns when using await/async