在需要OAuth2身份验证的API上运行E2E测试

时间:2019-02-01 23:32:22

标签: authentication oauth-2.0 xunit e2e-testing

我的ASP.NET Core App有很多基于Xunit测试框架的E2E测试用例。这些测试采用不同的[inlindata],并在调用我的控制器之一的相同代码上运行。

我最近对该控制器实施了OAuth2身份验证,现在我的测试用例无法通过。

我可以在上面的代码中包含获取令牌的代码,但是随后它将尝试为每个[inlinedata]一次又一次地获取令牌。有什么办法可以一次获取令牌并将其用于所有[inlinedata]吗?

[inlinedata(file1)]
[inlinedata(file2)]
Public async Task RunTestCaseAsync(testcasefile)
{
 //read test case file
 // Make HTTP call to controller which requires authentication
}

0 个答案:

没有答案