Archive Page 3

Important: Don’t miss out on future TFS-related posts. Subscribe to the new feed: http://blogs.msdn.com/granth/atom.xml

Today was my second day as a full time blue badge Microsoft employee. After a day and a half of New Employee Orientation (NEO) & kool-aid drinking, we all got smart cards and CorpNet logons. One of the first things I did after inserting the Microsoft e-mail intravenous line was setup a new blog on MSDN.

Woohoo! Got my blue badge

Why three blogs?

http://OzGrant.com/ will be my personal blog. I’ll talk about the visa, relocation & cultural experiences of my time here. This will be one of the ways I’ll stay in touch with friends & family back home in Australia.

http://blogs.msdn.com/granth/ will be my work blog. A purely TFS/Microsoft focused blog.

http://moblog.OzGrant.com/ will be my photo blog. This is where I take photos using my phone and upload them to a blog - it’s a great way to share experiences.

What about all the old content?

Don’t worry, it’s not going anywhere. All the existing content will remain where it is - just new technical content will go up on MSDN so as not to bore friends & family :)

However, feel free to stay subscribed to this blog - some of the future topics I want to cover are:

  • Packing up a house for international relocation
  • Getting a US E-3 Visa for Australians
  • Getting a hire car, driving on the opposite side of the road & other driving hazards
  • Grocery shopping & rewards cards
  • Looking for rental accommodation
  • Skype & SkypeIn for great communication back home

Visual Studio 2008 introduced a feature that detects where the current Team Foundation Server is online or offline when you start the IDE.

In the situation where your server is actually ONLINE, but you want to treat it LIKE it’s offline, you have a couple of options.

Option 1 - Use the ‘tfpt tweakui’ utility

You can edit the server setting and go offline.

  • Close Visual Studio
  • Download and install the latest Team Foundation Power Tools
  • Start a Visual Studio Command Prompt
  • Type: tfpt tweakui
  • Open the server
  • Check the [X] Server is offline checkbox
  • Open Visual Studio

tfpt tweakui dialog

Option 2 - Yank the network cable before starting Visual Studio

Obviously the IDE won’t be able to contact the server, and will inform you that it is now offline.

Option 3 - Set a registry key

Create a *.reg file with the following text in it, and run it before starting Visual Studio.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers\SERVERNAME]

"Offline"=dword:00000001

"AutoReconnect"=dword:00000000

When you want to go back online, you can either go to "File | Source Control | Go Online", or delete this registry key.


If you’re doing a deployment out to a test server as part of your Continuous Integration build process, you may have some unit tests (or web/load tests) to run after the deployment. Since these tests are testing more than just an assembly, they can be considered integration tests.

This can easily be accomplished by modifying your TFSBuild.proj script. Start by overriding the AfterDropBuild or similar MSBuild target and calling the <TestToolsTask> with the correct parameters.

First of all, you’ll need to define the tests that you want to run. The simplest way is to create a Test List called “Integration Tests” that gets saved in your test metadata file (*.vsmdi).

<ItemGroup>

  <IntegrationTestList Include=”$(SolutionRoot)\src\MySolution.vsmdi”>

    <TestList>Integration Tests</TestList>

    <FlavorToBuild>Release</FlavorToBuild>

    <PlatformToBuild>Any CPU</PlatformToBuild>

  </IntegrationTestList>

</ItemGroup>

There are two additional properties that we need to set, they are the Platform and Flavor. The reason for this is that when MSTest.exe tries to publish the integration test results to TFS, it needs to know what platform/flavor build to build against. And since we are doing this in AfterDropBuild, the configuration information isn’t available.

If your application requires additional files, or extra test run settings, you will need to specify them with a Test Run Config file:

<PropertyGroup>

  <RunConfigFile>$(SolutionRoot)\src\MySolution.testrunconfig</RunConfigFile>

</PropertyGroup>

And finally we can override the AfterDropBuild target to run the test list:

<Target Name=”AfterDropBuild”>

  <!– Execute Integration tests against remote server. –>

  <TestToolsTask

    Condition=” ‘$(IsDesktopBuild)’!=’true’ and ‘%(IntegrationTestList.Identity)’!=””

    BuildFlavor=”%(IntegrationTestList.FlavorToBuild)”

    Platform=”%(IntegrationTestList.PlatformToBuild)”

    PublishServer=”$(TeamFoundationServerUrl)”

    PublishBuild=”$(BuildNumber)”

    SearchPathRoot=”$(OutDir)”

    PathToResultsFilesRoot=”$(TestResultsRoot)”

    MetaDataFile=”%(IntegrationTestList.Identity)”

    RunConfigFile=”$(RunConfigFile)”

    TestLists=”%(IntegrationTestList.TestList)”

    TeamProject=”$(TeamProject)”

    TestNames=”$(TestNames)”

    ContinueOnError=”true” />

</Target>

Now when you view the Team Build results, you will have two sets of Test Results published against the single build.


HP’s Quality Center (QC) is primarily used for it’s defect tracking and test suite management capabilities. More recently they have released a Requirements Management module that is able to tracks requirements.

If you want to query and update the data programmatically, it’s actually quite simple using what they call their “Open Test Architecture” APIs.

  • Add a reference to: C:\Program Files\Common Files\Mercury Interactive\Quality Center\OTAClient.dll

To get this dll on your machine, you’ll need to have logged in to the QC web interface and installed the ActiveX objects.

Then you can query all Requirements by using TDAPIOLELib.ReqFactory.NewList(optional filter):

TDAPIOLELib.TDConnection connection = new TDAPIOLELib.TDConnection();

connection.InitConnectionEx(”http://SERVER:8080/qcbin“);

connection.Login(”USERNAME”, “PASSWORD”);

connection.Connect(”QCDOMAIN”, “PROJECT”);

TDAPIOLELib.ReqFactory reqFactory = connection.ReqFactory as TDAPIOLELib.ReqFactory;

TDAPIOLELib.List requirementsList = reqFactory.NewList(”");

foreach (TDAPIOLELib.Req req in requirementsList)

{

  // View / Modify the properties

  // req.ID, req.Name, etc.

  // Save them when done

  // req.Post();

}

Querying Defects is much the same, just substitute ReqFactory for BugFactory. Enjoy.

Update: And to create new ones, you have to call reqFactory.AddItem(Nothing) in VB, or req.Additem(System.DBNull.Value) in C#.