Today I’d like to write about a new offer from Microsoft — Team Foundation Service in the cloud. For now everything is free so this is a great time to play with this technology.
After great success of cloud-version source control I was 100% sure that Microsoft has to react and give their service. Especially because they have already a good product like TFS (after Perforce I really love TFS J). As I said for now TFS is a preview so everything is free. At 2013 a new price will be announcing. However, free plan will include max 5 users at system and some limit for builds (which in my opinion — ideally for small start-ups and freelancers). Previously I used Dropbox + SVN for all my freelance/home projects. Then I’ve switched almost everything to Bitbucket. However, all of this solutions don’t have continuous integrations, test runner and project planning (especially for agile, where TFS always was much-much better then jira).
In this article I’d like to show how easily we can create a simple application, host it at TFS in the cloud, setup continuous integration for each check-in and use not Microsoft test framework.
Host application at TFS preview.
Let’s start. First of all you need register at TFS preview with your live id (BTW: a new web outlook is really good as for me, so you can setup live id there).
First step, we need give a name for a new project and select process template which we will use. For now there are only 3 templates:
- Microsoft Visual Studio Scrum (This template is for teams who follow the Scrum methodology and use Scrum terminology),
- MSF for Agile Software Development (This template is flexible and will work great for most teams using Agile planning methods, including those practicing Scrum),
- MSF for CMMI Process Improvement (This template is for more formal projects requiring a framework for process improvement and an auditable record of decisions).
Then you should wait few moments when project will be ready.
And eventually here it is.
This is a default project view. Here you can directly see burndown chart, add product backlog item, task or item and also see people from the project team.
We should choose “Open new instance of Visual Studio” menu item. It will launch a new instance of Visual Studio. Let’s create some project. I’ll choose ASP.NET MVC 4 Web Application with Web API project template. Now it’s time for our first check-in (of course with commentJ)
As you can see our new “CI hello world” application is already at TFS.
As you can see actually our first changeset is not first. TFS automatically mades some changes at the beginning.
Setup continuous integration with Microsoft test provider.
Next step, we should setup build configuration (in our case I would like to trigger it each time on a new check-in). Go to the “Build” section in Team Explorer and select “New build definition”. After this we need setup simple wizard. There are few properties such as name, description and etc. But most interesting for us is trigger section. In our case “Continuous integration — build each check-in” should be selected.
Let’s make some changes at the code and check-in it. Then as you can see at Build section in Team Explorer our check-in triggers a new build and it was succeed. However, there are no tests yet.
Let’s add some test project with a first MS test. As you can see — it should fail.
Note: we can specify to run all tests each build though Test->Test Settings->Run Tests After Build.
After check-in at Build page we can see that TFS automatically finds a test provider and runs all tests at solutions. Actually there is only one test and as we expected, it fails.
When we fix it and check in we can see positive result. About build result you can find information also at Visual Studio. In this time build was succeed too and test is green. Nice J
Setup continuous integration with non-Microsoft test provider.
A lot of people in real product prefer not use MS test framework. I like to work with xUnit test framework. So let’s add some new test, this time xUnit with Fluent Assertions (I really like to write test with this tool because tests become more readable at TDD and BDD style). In my project this is a production configuration so this example will be as much closer to real project as possible.
As you can see it will be failed.
Note: with Fluent Assertions in our case we can write:
As for me this is really understandable and intuitive. Also we have an IntelliSense depends on model type (in our case it’s Boolean).
When we change it to the correct form and check-in at Build details we will find strange info: there is only one “FirstTest” test (MS test framework) at our solution. To fix this case we need manually say TFS which test provider to use. For this I created a new “lib” folder at project and unzip xUnit dlls there. There is a small tricky thing: when you will add that folder to the solution doesn’t forget to exclude items. However, after check-in we still have only one MS test.
Let’s solve this. We need to go to the Build section at Team Explorer and select Manage Build Controllers.
At properties we need specify our new “lib folder”. So we say to TFS add these assemblies to CI too.
As you can see now there are too tests at solutions and both of them are green.
In this article I described how to setup a new environment at Microsoft new Team Foundation Service preview, how to configure continuous integration, add agent to trigger build on each check-in and how to use non-Microsoft test provider at CI. Hope you will enjoy!