Monthly Archives: September 2008

Setting the Test Run Config in Team Build

At my current client, we’re in a situation where a couple of us have Visual Studio 2008 Team System and the rest have Professional Edition. This means that we’ve been having a hard time with getting Code Coverage in our team build because everyone has been changing the active test configuration to suite their environment.

After trawling through a few blog posts and support forums, I finally discovered a gold nugget. In a couple of steps, I defined the test configuration and get it to run as part of the team build.

Firtsly, I added the following test arguments to my project build file (TFSBuild.proj):

<MetaDataFile Include="$(SolutionRoot)/HelloWorld.vsmdi">
  <TestList>HelloWorldUnitTests</TestList>
  <RunConfigFile>$(SolutionRoot)/TeamBuildTestRun.testrunconfig</RunConfigFile>
</MetaDataFile>

This defines the test metadata file (HelloWorld.vsmdi), the list of tests to execute (HelloWorldUnitTests) and the configuration file to use (TeamBuildTestRun.testrunconfig). However, only the metadata file and test list will be included to the MSTest command. To get it all working, we have to edit the targets file on the server C:\Program Files\MSBuild\Microsoft\VisualStudio\Team\Microsoft.TeamFoundation.Build.targets. There is a target called CoreTestConfiguration that calls the TestToolsTask MSBuild task with the parameters. The first three calls are for non-desktop (i.e. server) builds, e.g.

<TestToolsTask
      Condition=" '$(IsDesktopBuild)'!='true'
                  and '$(V8TestToolsTask)'!='true'
                  and '%(LocalMetaDataFile.Identity)' != '' "
      BuildFlavor="$(Configuration)"
      Platform="$(Platform)"
      PublishServer="$(TeamFoundationServerUrl)"
      PublishBuild="$(BuildNumber)"
      SearchPathRoot="$(OutDir)"
      PathToResultsFilesRoot="$(TestResultsRoot)"
      MetaDataFile="%(LocalMetaDataFile.Identity)"
      RunConfigFile="%(RunConfigFile)"
      TestLists="%(LocalMetaDataFile.TestList)"
      TeamProject="$(TeamProject)"
      TestNames="$(TestNames)"
      ContinueOnError="true" />

When the build is run on the server, the values of the MetaDataFile property are copied to the LocalMetaDataFile variable. This means the RunConfigFile property needs to be changed to %(LocalMetaDataFile.RunConfigFile), e.g.

<TestToolsTask
      Condition=" '$(IsDesktopBuild)'!='true'
                  and '$(V8TestToolsTask)'!='true'
                  and '%(LocalMetaDataFile.Identity)' != '' "
      BuildFlavor="$(Configuration)"
      Platform="$(Platform)"
      PublishServer="$(TeamFoundationServerUrl)"
      PublishBuild="$(BuildNumber)"
      SearchPathRoot="$(OutDir)"
      PathToResultsFilesRoot="$(TestResultsRoot)"
      MetaDataFile="%(LocalMetaDataFile.Identity)"
      RunConfigFile="%(LocalMetaDataFile.RunConfigFile)"
      TestLists="%(LocalMetaDataFile.TestList)"
      TeamProject="$(TeamProject)"
      TestNames="$(TestNames)"
      ContinueOnError="true" />

There are three more calls to TestToolsTask that should be modified. These calls are for desktop builds, so the LocalMetaDataFile has not been created. This means we use %(MetaDataFile.RunConfigFile) instead, e.g.

  <TestToolsTask
        Condition=" '$(IsDesktopBuild)'=='true'
                    and '$(V8TestToolsTask)'!='true'
                    and '%(MetaDataFile.Identity)' != '' "
        SearchPathRoot="$(OutDir)"
        PathToResultsFilesRoot="$(TestResultsRoot)"
        MetaDataFile="%(MetaDataFile.Identity)"
        RunConfigFile="%(MetaDataFile.RunConfigFile)"
        TestLists="%(MetaDataFile.TestList)"
        TestNames="$(TestNames)"
        ContinueOnError="true" />

And that’s it!

Moving Blogs

For those on twitter, you may have noticed that my latest posts look a bit different to my old ones. I’ve finally made the decision to move my blog across to WordPress (event though I’ve had an account for 6 months).

I’ve updated my feedburner feed to point to the right place, but now I have to get the rest of it going. Hopefully once it’s all up and running I’ll have my posts and comments all up on my new blog. In the meantime, please bare with me while I make this transition.

Thanks!

#teau08

NOTE: This is possibly the longest thing I’ve ever written. Please stay tuned, because the people I mention really deserve recognition.

Last week I attended Tech.Ed Australia 2008. It was the third Tech.Ed I’ve attended, but for some reason it has stood out far above the rest. I had a great week from beginning to end.

The experience started Tuesday morning for me, when I turned up to the Embedded Developers Pre-Day. This involved sitting in an instructor-led lab for a day and delving into the embedded experience. Before Tuesday my embedded experience basically involved a bit of Windows Mobile and XP Embedded development. The day introduced some great concepts to me including componentising an application, working with the File-Based Write Filter and using debugging with CeDebugX ("!diagnose all" will save my life…).

Wednesday saw the kick-off of Tech.Ed and some worthwhile sessions. The most memorable was Corneliu Tusnea’s Debugging the World session. I’ve seen this before, but it was still the highlight of the day to me. The way he works with WinDebug truly amazes me. Some people think it’s a bit technical, but I thought it’s what a 400 session should be! It was also great watching Scott Hanselman (who I was honoured to meet *briefly*) go up against the Readify greats Corneliu and Mitch in the Ask the Experts session that night.

Thursday was a bit more lively and turned into a very long day. It started off well with Jonas’ Silverlight presentation. It got a bit worse at morning tea when my nerves got the best of me while I gave my first (and hopefully not the last) presentation at Tech.Ed on Introducing Windows Mobile Development. A bit of fun and the demo gods smiled on me for once…

Scott Hansleman’s MVC presentation was an absolute hoot! The demo gods were definitely not so kind to him, but he worked through it and did an excellent job. I thought this session was a bit too technical for a 200 level, but I wouldn’t expect any less than 10 minutes in the call stack from Scott.

Paul Stovell delivered a really good presentation on reactive programming that was great at introducing advanced concepts of databinding in all forms. Backed up by Corneliu’s next session on Secure Development Patterns, which will hopefully be coming to an RDN near you…

Once again, Scott had me riveted in his afternoon session on REST and ADO.Net Entity Data Services. I now want to be a RESTifarian. Then, I finished off with Harry Pierson’s dynamic languages presentation, which was really interesting. Of course, that was followed by the closing party…

Friday was a great end to the conference. I really Joel Pobar’s F# presentation, and I can’t wait to introduce it as an alien artifact. The Mobility Smackdown was once again a really pumped session with the aim of promoting Windows Mobile. I managed to score an Xbox 360, so I really really enjoyed that too… Finally, the Locknote. Two words- passionate and Wow! Craig Bailey really summed it up well here. It’s the best locknote (or keynote) session I’ve ever seen and I just hope both ends of the conference are more like that next year.

Final Thoughts…

I had a great week. Learned loads of cool stuff. Really excited about cloud computing and the future of the web, but also about what I can do to be a better developer. Microsoft really put on a great show and I can’t wait until next year. Also, thank you to all the people that were involved in Tech.Ed that I may have missed.

The only plus in it being over is that my liver finally gets a rest… =P