Showing posts with label mstest. Show all posts
Showing posts with label mstest. Show all posts

Monday, June 10

Continuous Delivery of ASP MVC with Jenkins and MSDeploy

We have been using Jenkins to deploy our web application for a while using continuous deployment, that is we used to push our changes into our git repository, go into Jenkins and run the deployment job.
Last month after successfully working in this way we decide we can trust ourselves and our systems and move to continuous deployment (or more accurately continuous release).

The ingredients

We divide the deployment process into several jobs and connect them all together using CloudBee Build Flow plugin.

The Jobs
  1. build & test - This job build and test both debug and release configuration of our web application
  2. deploy - This job deploy our web application using MSDeploy
  3. end-to-end-tests - This job run end-to-end test on our production web application using Watir web testing framework
  4. continuous delivery - This job is a build flow job that simply run jobs 1,2,3 in order. If anything goes wrong it notify us.
What's still missing?
  1. Staging - We are working on deploy our web application into staging environment and run the end-to-end test on it. This does not guaranty success but it does catch errors. 
In the next posts I'll go into details about each of the jobs.

Saturday, June 1

MSTestRunner for Jenkins is now 1.0.0

I'm happy to let you know that my Jenkins plugin MSTestRunner has reach version 1.0.0
The major change is that the plugin now support running unit test containers (DLLs) in path that has space in it.
It was requested from people having path inside the workspace with spaces as well as people who want to run unit test that are not inside the Jenkins workspace and use full path.

This is also great place to say the plugin usage statistics show it is used by almost 1,000 developers.
Compare it to MSBuild plugin which has over 6,000 developers it mean 1 of 6 .NET developer run unit test in the CI server. This is nice statistics by itself :)

Thank you very much to all the developers who use this plugin and thank you very much for everyone who helped by contributing code or simply explain how it can be improved.

Sunday, November 13

Building .NET Application with Jenkins using MSBuild and MSTest

Objective
Quick feedback to the developers and transparent information about the health of the projects. This post will focus on .NET application.

Environment
Small team of 3 developers. Two projects: .NET WPF client application and J2EE RESTful web service.

Why Jenkins

I've decide to use Jenkins as Continuous Integration server. I've use CrouseControl.NET in the past but was not so happy about it. TeamCity was another very good option and I've decide on Jenkins after all because of the strong community involvement and quick development around it, and also the fact that it is free and stay free was important factor.

Notice
Those instructions are given as-is without warranty. Use them at your own risk. You should ensure you have the proper license to run each tool on your machines.

Step-by-step

  1. Download Jenkins for Windows.
  2. Run Jenkins setup. Install it in C:\CI\Jenkins (no spaces in name)
  3. Stop Jenkins service, open Jenkins.xml and change http port to 6080. Restart the service.
  4. Open http://localhost:6080 to confirm Jenkins installation
  5. Install GitExtensions to C:\CI\GitExtensions. Install msysgit co C:\CI\git
  6. Go into Jenkins configuration -> Plugins -> Available and install git plugin. Go into Jenkins -> Configuration and change Path to git execution to C:\CI\git\cmd\git.cmd (not git.exe)
  7. Change Jenkins windows service to run with specific Windows user by open the Services mmc, open the Properties dialog for Jenkins service and change the login user to a user in your machine.
  8. Login with the user and run command to create ssh public/private key: open git bash goto ~/.ssh and run ssh-keygen.exe -t rsa -C "your-name@your-domain.com"
  9. Use the command cat id_rsa.pub in git bash to get the public key (remove new lines)
  10. Paste the public key in the remote git site (assembla, github).
  11. Create new build task. Choose git as SCM and enter your remote repository address.
  12. Run the build task, which will hang, stop it after few seconds and copy the command Jenkins execute. Paste that command into command line window and run it. You will get a message ask to approve the remote service fingure print, approve it.
  13. Run the task again and everything should work as planed.
  14. Go into Jenkins configuration -> Plugins -> Available and install MSBuild plugin
  15. Go into Jenkins configuration and under MSBuild click Add MSBuild in the name enter .NET 4 and in Path to MSBuild enter C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
  16. Download Windows SDK for .NET 4 - select GRMSDK_EN_DVD.iso. Install only ".NET Development" component. (Update: Please download Windows 8.1 SDK if you are using Windows 8 and above).
  17. Using this script copy MSTest related files from your development machine into CI server at C:\CI\MSTest
  18. Use gacutil from Windows SDK to register ".Resource.dll" and ".UnitTestFramework.dll" - it is important the files will have version 10.0.0.0 (not 10.1.0.0)
  19. Run mstest registry file [MSTest Registry Export] to add test types and other values request by MSTest to the CI server registry
  20. Go the the job configuration and add build step of type Execute windows batch command with the following command Test Batch Command
  21. Go into Jenkins configuration -> Manage Plugins -> Available -> and select  JENKINS MSTest plugin
  22. Go into the build configuration. In the Post Build Actions check Publish MSTest test result report and write TestResult.trx in Test report TRX file
[MSTest Registry Export]
You will need to export values from your registry in order to run MSTest on Jenknis machine.
For 32bit machines export HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\EnterpriseTools\QualityTools
For 64bit machines export HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\EnterpriseTools\QualityTools

If you have 64 bit developer machine and 32 bit Jenkins server just do search and replace of Wow6432Node\ to nothing to remove the 64 bit registry path part.

[Test Batch Command]
del /f /q TestResult.trx
    C:\ci\mstest\mstest.exe /noisolation /resultsfile:TestResult.trx /testcontainer:Project\Project.Test.dll

    Sources
    I've use the following posts and articles to build my Jenkins server.

    Jenkins

    http://zeljkofilipin.com/jenkins-windows-and-git/


    unit test without VS

    Conclusion
    I've only start using Jenkins now but it already helping to improve our project. It took about 4 late nights to play with it and set it up but I think it worth the trouble.
    Next I'm going to add deployment package creation automation, after this will be solid I hope to get to continuos deployment by pushing the packages to our web site.
    Also add build task for our J2EE web service and finally put a wall-screen to present the state in our development room.