简体   繁体   English

由于Specflow测试而导致构建失败

[英]Build failing because of Specflow tests

Builds in Visual Studio Team Services build fail when we do not ignore specflow tests. 当我们不忽略specflow测试时,Visual Studio Team Services构建中的构建就会失败。 All our tests return with a http status code 401 auth fail when actually expect a 200 or 422 etc. This only happens on our Visual Studio Team Services builds, when those tests are run locally they all pass. 我们所有的测试返回的HTTP状态代码401 auth会在实际上期望200或422等失败时失败。这仅发生在我们的Visual Studio Team Services版本中,当这些测试在本地运行时,它们全部通过。 We specify the username and password in the specflow test, theyre hardcoded, so why does this not work or fail auth when being built on Team Services? 我们在specflow测试中指定了用户名和密码,这些用户名和密码是经过硬编码的,因此在Team Services上构建用户名和密码时为什么不起作用或无法通过身份验证?

Eg 例如

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

This was happening because the transform of the connection strings happen on publish and not on build. 之所以发生这种情况,是因为连接字符串的转换发生在发布而不是构建上。 So when it was being built, the server did not have access to the connection that was declared on my local connection strings (as the transform did not happen). 因此,在构建服务器时,服务器无权访问在我的本地连接字符串上声明的连接(因为转换没有发生)。 I was assuming that on build the transform happens for the connection string. 我以为在构建时转换发生在连接字符串上。 That is not the case, transform happens only on publish. 事实并非如此,转换仅在发布时发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM