确切的情况是,我正在使用Protractor.NET(AngularJS的Protractor E2E框架的.NET端口)进行E2E测试,我想发出一些Web请求(并且API-System.Net.Http.HttpClient-具有所有异步功能/Task方法)在我执行/声明之前安排测试,只需要对几个测试进行相同的安排即可.
The exact situation is I'm doing E2E tests with Protractor.NET (.NET port of AngularJS's Protractor E2E framework) and I would like to make some web requests (and the API -- System.Net.Http.HttpClient -- has all Async/Task methods) to Arrange my test before I Act/Assert, only I need to do this same Arrange-ing for several tests.
我将xUnit用作我的测试运行程序,他们使用接口(IUseFixture<T>)来为每个灯具设置代码.如果有一个IAsyncUseFixture<T>带有一个Task SetFixtureAsync(T t);或类似的东西,那将是很好的.我认为这样的事情不存在.另外,我也不认为构造函数也可以使用await,并且构造函数是在xUnit中每次测试执行相同代码块的唯一其他方法.
I'm using xUnit as my test runner they use an interface (IUseFixture<T>) for per-fixture setup code. It would be nice if there was a IAsyncUseFixture<T> that had a Task SetFixtureAsync(T t); or something. I don't think such a thing exists. Additionally I don't think constructors can use await either, and constructors are the only other way to execute the same block of code per-test in xUnit.
我有什么选择? .Result?那不是不好的做法(僵局)吗?
What are my options? .Result? Isn't that bad practice (deadlock)?
推荐答案我刚使用.Result.到目前为止,一切都很好.
I just went with .Result. So far, so good.
更多推荐
在xUnit.net中等待测试设置代码中的任务吗?
发布评论