Chris Patterson's Blog

Father, Technologist, Photographer, Triathlete

Disabling Presence in TFS Power Tools

Posted by chris on October 2, 2009 19:18 in Team System

The July 2008 Power Tools release for Team Foundation Server contains some really great additions to the product.  One of the more interesting features is the addition of a Team Members node to your team explorer.  This feature allows you to keep track of your team members, what they are doing and their presence information right inside Visual Studio.

However, that presence information comes from either Live Messenger or Office Communicator and in some cases if you aren’t logged into the client you will see an error.  To avoid that error, you can disable presence information in the Personal Settings dialog.

Select the Personal Settings… menu item from the context menu on the Team Members node

image

From the dialog click the “Change…” button in the collaboration group

image

And from the Choose a Collaboration Provider dialog you can select <None>

image

At that point you can OK your way out and you should be good to go.

Publishing Test Results with VSTS 2010 TCM API

Posted by chris on August 11, 2009 22:07 in Team System

In Visual Studio Team System 2010 we have made some huge steps forwards in software testing.  Specifically we have invested in test management, manual testing, UI automation and lab management.  If you would like some background information you can check out the following blogs:

My primary area of focus for this release has been the test management server and its public object model, so I plan to give some focus to that here.  The OM we have built is the same layer that drives the new test management client that is shipping in VSTS 2010.  So any of the data that you view and manipulate there, you have access to through our public object model.

There are a variety of different directions I could go when trying to give an overview of our API.  I could put up some UML diagrams and talk about the major object and what they do, or I could just provide some targeted samples. In most cases people aren’t that interested in the design of the API or even an general overview.  What most people want is samples on how to accomplish specific tasks.  To that end I plan to provide an indeterminate number of posts that use the API to do specific things that I have been asked about.

How do I get my test results into TFS so I can report on them if I am not using TFS Build and MSTest?

That is one of the most common questions we have gotten sense version 1 of Team System with regards to test results and a public API.  Unfortunately, in the first two release there was no good way to do this, your only option was to transform your test results file into our format and then publish with mstest.exe.  While this was functional, it was difficult to do and error prone.  With VSTS 2010 we have a nice .NET object model that will let you directly manipulate the runs and results on the server and hopefully give you a better shot at integrating our store into your build system.

Creating runs and results

The test management service is installed as part of any TFS 2010 server and generally works in the same way as other TFS services.

The first thing you will need to do is get a instance of our service and then get a reference to the TCM store for your team project

string collectionUrl = "http://chrispat-dev:8080/tfs/DefaultCollection";
string projectName = "chrispat.unit.1";

// get our team foundation connection using the executing user
TeamFoundationServer server = new TeamFoundationServer(collectionUrl);

// get the test management service and the store for our team project
ITestManagementService testManagement = server.GetService<ITestManagementService>();

ITestManagementTeamProject teamProject = testManagement.GetTeamProject(projectName);

Once you have that reference you will need to create a build to publish your results against. This can either be a build record that you simply use as a hook for reporting purposes or you can reference a build that you have actually executed through team build.  I have included code in the attached sample on how to create  a build definition and a build.

After you have a build you are ready to create a run and add test results to it.

// Create a run to hold our results
ITestRun testRun = teamProject.TestRuns.Create();
testRun.BuildFlavor = "Debug";
testRun.BuildPlatform = "Any CPU";
testRun.BuildNumber = build.BuildNumber;
testRun.BuildUri = build.Uri;

LoadTestResults(testRun,teamProject);
// read an NUnit results file and add the resuts to the run.
private static void LoadTestResults(ITestRun testRun, ITestManagementTeamProject teamProject)
{
    XmlDocument results = new XmlDocument();
    results.Load("TestResult.xml");

    // set some run properties
    XmlNode run = results.SelectSingleNode("/test-results");
    testRun.Title = run.Attributes["name"].Value;
    testRun.DateCompleted = DateTime.Parse(string.Format("{0} {1}", run.Attributes["date"].Value, run.Attributes["time"].Value));
    testRun.IsAutomated = true;
    testRun.IsBvt = true;
    //go ahead and attach the log as well
    testRun.Attachments.Add(testRun.CreateAttachment("TestResult.xml"));

    XmlNodeList testCases = results.SelectNodes("/test-results/descendant::test-case[ancestor::*[parent::*][count(*)=1]]");

    List<ITestCaseResult> tcmResults = new List<ITestCaseResult>();
    foreach(XmlNode testCase in testCases)
    {
        // this is for our execution system, but should not be required, by beta you won't need this line
        ITmiTestImplementation implementation = teamProject.CreateTmiTestImplementation(testCase.Attributes["name"].Value, "NUNIT", "", Guid.Empty);

	// Add a test to our run, pull the key attributes from the NUnit xml result file
        ITestCaseResult result = testRun.AddTest(0, testCase.Attributes["name"].Value,string.Empty, implementation);
        result.Duration = TimeSpan.FromSeconds(Convert.ToDouble(testCase.Attributes["time"].Value));
        result.Comment = testCase.OuterXml;
        result.State = TestResultState.Completed;

	// set the outcome on the result
        if (testCase.Attributes["executed"].Value == "True")
        {
            
            if (testCase.Attributes["success"].Value == "True")
            {
                result.Outcome = TestOutcome.Passed;
            }
            else
            {
                result.Outcome = TestOutcome.Failed;
            }
        }
        else
        {
            result.Outcome = TestOutcome.NotExecuted;
        }
       
	// add the result to our list so we can batch save at the end
        tcmResults.Add(result);
    }
    
    // save the run
    testRun.Save();
    // batch save the results to the server
    teamProject.TestResults.Save(tcmResults.ToArray(), false);
}

That is pretty much it, not a whole lot of code and fairly straight forward.  I have attached a project to this post that contains a working sample that you can use in your own solution.

TCMSamples.zip

Scotts Take on my Portrait

Posted by Chris on June 17, 2009 15:53 in Photography

Overall I can’t be more pleased with the critique as I feel this is one of the better portraits I have taken. I really like the composition, the lighting and the post processing.  As it turns out Scott agreed and really only had a few minor things he would change.

Scott Bourne over has posted his take on my portrait and you can read the full critique here.

It is great to have an impartial professional take a look at your best work and not only tell you it is good but show you how you can make it even better. Hopefully as I continue to improve I will eventually make some money with this hobby

Don’t You Just Love Government

Posted by Chris on June 17, 2009 15:34 in Musings

I received the following email from Amazon.com today

We regret to inform you that the North Carolina state legislature (the General Assembly) appears ready to enact an unconstitutional tax collection scheme that would leave Amazon.com little choice but to end its relationships with North Carolina-based Associates. You are receiving this e-mail because our records indicate that you are an Amazon Associate and resident of North Carolina.

Please note that this is not an immediate termination notice and you are still a valued participant in the Associates Program. All referral fees earned on qualified traffic will continue to be paid as planned.

But because the new law is drafted to go into effect once enacted – which could happen in the next two weeks – we will have to terminate the participation of all North Carolina residents in the Amazon Associates program on or before that same day. After the termination day, we will no longer pay any referral fees for customers referred to Amazon.com or Endless.com nor will we accept new applications for the Associates program from North Carolina residents.

The unfortunate consequences of this legislation on North Carolina residents like you were explained in detail to key senators and representatives in Raleigh, including the leadership of the Senate, House, and both chambers’ finance committees. Other states, including Maryland, Minnesota, and Tennessee, considered nearly identical schemes, but rejected these proposals largely because of the adverse impact on their states’ residents.

The North Carolina General Assembly’s website is http://www.ncleg.net/, and additional information may be obtained from the Performance Marketing Alliance at http://www.performancemarketingalliance.com/.

We thank you for being part of the Amazon Associates program, and we will apprise you of the General Assembly’s action on this matter.

Sincerely,

Amazon.com

I am not even sure how to comment on this, other than to say ”Don’t you get enough of my money”. 

It is amazing how the state of North Carolina will give away hundreds of millions of dollars to Dell, Google and Apple to get them to create a few hundred jobs here and in the same breath they will pass laws to collect taxes on the very tiny amount of money I may or may not make from some Amazon.com referrals.

Give me a break.

New VSTS Load Test Integration on CodePlex

Posted by Chris on June 16, 2009 16:25 in Team System

Project Description

This tool takes a WCF trace file and a WCF client proxy, or a WCF interface contract, and generates a unit test that replays the same sequence of calls found in the trace file. The code generated is easily modifiable so that data variation can be introduced for the purpose of doing performance testing.
The tool generates code for both Visual Studio 2005 and Visual Studio 2008. It also installs a wizard into both editions of Visual Studio for creating the trace and processing it from inside Visual Studio. If both editions are present the tool is installed into both editions. The source code is a Visual Studio 2005 project.

Latest Release June 2009

A new beta was released in June 2009 adding support for ASMX web services. Download it from here.

Features

  • Replay of captured scenario in a unit test that can be included in a load test.
  • Support for the DataContractSerializer.
  • Support for message contracts.
  • ASMX support (beta)
  • Support for proxies generated using svcutil.
  • Support for clients that create proxies at run time from contract interfaces.
  • Supports calls to multiple services in a single scenario.
  • Supports multiple calls to the same service operation.
  • Filtering by SOAP action of which messages in the trace to replay.
  • Readable and modifiable code is generated.
  • Automatic association of trace message with proxy method (requires all operations to have a unique SOAP action).
  • Support for client and server side traces.
  • A command line tool for processing traces and generating code.
  • Visual Studio 2005/2008 integration (Team Developer, Team Test, Team Suite and for 2008 also Professional)) that can be used instead of the command line tool.

An Interview with Scott Kelby

Posted by Chris on June 13, 2009 01:15 in Photography

Scott Bourne over at photofocus.com has an excellent interview with Scott Kelby.  Scott is known mostly as a Photoshop guy, however, I think he is an excellent photographer and one of my favorites.  I found the interview very interesting and I thought you might as well.

An Interview with Scott Kelby.

One of my photos being critiqued on flickr

Posted by Chris on June 9, 2009 07:36 in Photography

20090524_095320_AboretumPortraitsMay2009-BW

I am very excited that a portrait I recently took of my niece is being critiqued by Scott Bourne in the ScottCritiques group on flickr.

As an avid photographer, it is always good to have someone who is impartial look at your work and offer advice on how to make it better.  For the most part my work is seen by friends and family and the overwhelming response is “Fantastic” or “Those pictures are so good”.  While this may feel good, the reality is most of them don’t know what to look for or they are just being nice.

The portrait is part of a larger set I took of my nice for her 16th birthday.  As it turns out she was a very cooperative subject.  We had a great time roaming around the JC Raulston Arboretum finding interesting places that would make a good background for a portrait.

The image to the right is one of my favorites and was taken in the Japanese Garden.  One of the keys to a great outdoor portrait is a very simple background and good lighting. In this case the background was a beautiful  red Japanese maple, which given its color and busy leaves could have been too detailed.  However, to bring the background down and the subject out I chose a very wide aperture of f2.8.  The wide aperture has the effect of blurring the background in any photograph with a very shallow depth of field.  The means that if your focus is on your subject object that are immediately in front or behind them will be out of focus and this will help draw the viewers eyes to the primary subject of the image.

Secondly, I used an inexpensive reflector to direct some light onto my subject.  In this case my brother was standing to my left, subject right, at about a 45 degree angle.  As you can see in the image there is some sunlight coming in from the top right, providing a little rim light on her shoulder and hair.  Using the reflector we were able to take some of that light and direct it back into the front of our subject to give some dimension to her face and provide fill for the shadows thrown by the trees over head.

So far there have been a couple of posts with some very interesting options about what the photographer might change.  I am looking forward to seeing what Scott says at the end of the week and using any advice I get to further improve my work.

First Post

Posted by Chris on June 4, 2009 06:37 in

Well my new blog is up and running, complete with a theme I like and some good information.  Lets see if I can actually post something worth while here.