简体   繁体   中英

Build failing because of Specflow tests

Builds in Visual Studio Team Services build fail when we do not ignore specflow tests. 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. 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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