【问题标题】:Build failing because of Specflow tests由于 Specflow 测试,构建失败
【发布时间】:2016-06-19 07:02:09
【问题描述】:

当我们不忽略规范流测试时,Visual Studio Team Services 中的构建会失败。我们所有的测试都返回一个 http 状态代码 401 auth failed 当实际期望 200 或 422 等时。这只发生在我们的 Visual Studio Team Services 构建上,当这些测试在本地运行时它们都通过了。我们在 specflow 测试中指定了用户名和密码,它们是硬编码的,那么为什么在 Team Services 上构建时这不起作用或验证失败?

例如

2015-11-24T16:50:48.9936518Z ##[error]Error Message:

2015-11-24T16:50:48.9936518Z ##[error]     Expected: 200

2015-11-24T16:50:48.9936518Z ##[error]  But was:  401

2015-11-24T16:50:48.9936518Z ##[error]

2015-11-24T16:50:48.9936518Z ##[error]Stack Trace:

2015-11-24T16:50:49.0092775Z ##[error]at Test.Specifications.GetImageByIdSteps.ThenTheResultShouldBe(Int32 p0) in C:\a\1\s\Web\Web.Test\Specifications\GetImageByIdSteps.cs:line 36

2015-11-24T16:50:49.0092775Z ##[error]at lambda_method(Closure , IContextManager , Int32 )

2015-11-24T16:50:49.0092775Z ##[error]at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)

2015-11-24T16:50:49.0092775Z ##[error]at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments)

2015-11-24T16:50:49.0092775Z ##[error]at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance)

2015-11-24T16:50:49.0092775Z ##[error]at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()

2015-11-24T16:50:49.0092775Z ##[error]at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()

2015-11-24T16:50:49.0092775Z ##[error]at Web.Test.Specifications.GetImageByIdFeature.ScenarioCleanup() in C:\a\1\s\Web\Web.Test\Specifications\ImageGetImage.feature.cs:line 0

2015-11-24T16:50:49.0092775Z ##[error]at Web.Test.Specifications.GetImageByIdFeature.GetImage(String imageId, String userName, String password, String http_Status_Code, String[] exampleTags) in C:\a\1\s\Web\Web.Test\Specifications\ImageGetImage.feature:line 12

【问题讨论】:

  • 测试的目标部署在哪里?很有可能,运行 specflow 测试的服务器将无法看到它。
  • 如何在测试中验证身份验证?连接真实数据库还是使用mock数据库?
  • 我们所有的 specflow 测试都使用真实的数据库,因此我们在 specflow 场景大纲中提供了实际的用户名和密码。
  • 是构建失败,还是测试运行失败?您的问题标题令人困惑
  • 如果测试未通过,解决方案无法编译,导致构建失败/不编译/不编译。

标签: c# msbuild specflow azure-devops


【解决方案1】:

发生这种情况是因为连接字符串的转换发生在发布而不是构建时。因此,在构建它时,服务器无法访问在我的本地连接字符串上声明的连接(因为没有发生转换)。我假设在构建时连接字符串会发生转换。事实并非如此,转换仅在发布时发生。

【讨论】:

    猜你喜欢
    • 2020-01-16
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    相关资源
    最近更新 更多