1

I am using TeamCity to build a .dll containing a test suite for an api.  The api is composed of asynchronous calls to create/read/update/delete values in a database.  The tests in the .dll were created using specflow, xUnit and c#.  Some of my step definitions call the api methods with non-asynchronous code, like so:

public void DoSomething()
{
    Task.Run(() => client.ApiCall()).Result;
}

The tests that call the api in this fashion are executed successfully by TeamCity. If however I change the code for that same api call, so that the calling code is asynchronous,

public async Task DoSomething()
{
 await client.ApiCall();
}

the build will hang on that test.

Additionally, I have created a separate project, using XUnit but not SpecFlow, and made the same api call with async and await.  This version of the test does not hang the TeamCity build.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.