I have a build that I am trying to do in TFS2010 (server 2008R2) and it is not doing what I want it to do. I want the code to build (I have a gated check-in policy) and on successful build I want to run tests(Unit and integration tests) If (and only if) all tests pass I want the build to be deployed to out IIS7 server.
When starting the setup I started by ignoring tests to see if the build and deploy works. After I had this working I am now trying to get a tests to fail and that must prevent the deployment of the site.
In one of my tests (on purpose) I added Assert.IsTrue(1 == 2); and in the log I can see that the build failed but still the site is deployed to my IIS server. I have my MSBuild Arguments set to : /p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=RemoteAgent /p:MSDeployServiceUrl=http://111.11.11.111/msdeployagentservice /p:DeployIisAppPath=”MVC – Jack” /p:UserName=APP-107\Administrator /p:Password=xxxxxx /p:Configuration=Release
Why is the deploy still happening even if the test fails and I have the build definition set to “Disable Tests = false” and “Fail build on test failure”
Thank you
Jack
Ps. I there maybe and example out there that explains how to modify BuildProcessTemplate.xaml to stop the deploy on failing a tes?
The MSBuild Activity in the DefaultBuildTemplate.xaml runs before any of your tests do. Therefore it will do the same thing always regardless of your test results. To rectify this, add a MSBuild Activity after the tests in the DefaultBuildTemplate.xaml in the “If Tests Successful” branch and deploy in that activity.