# Friday, September 25, 2009

Disclaimer:  I’m writing this at a time when only Beta 1 is available for Visual Studio Team System 2010 so the information may have changed by the time it has been released.  I have included links to the relevant MSDN articles which should remain valid after release time so just double-check.

This small little additional feature is actually one that I have been looking forward to for a long time.  In Visual Studio Team System and Team Foundation Server 2010, you will now be able to limit your test runs to specific test categories with a new command-line option on MSTest.exe and therefore in Team Build 2010 which calls MSTest.exe automatically for you.

Back in the day… You would need to create test lists (.VSMDI files) in VSTS 2005 and VSTS 2008 to basically “categorize” your automated unit tests by putting them into different lists.  One handy thing about them is that the lists could be hierarchical which helps out at build time.  When you wanted to run a specific subset of tests either locally using MSTest.exe or in Team Build, you would just specify the .VSMDI file to use and then the test list you wanted to run.  Not too bad, but it’s a pain to keep up with those test lists.  Serious pain.  However, the thing that I hated absolutely most about them is that you could only edit the .VSDMI files if you purchased Visual Studio Team Suite or the Tester Edition.  So that means that if you have just the VSTS Developer Edition then you are pretty much out of luck.  For most places that I have seen, it’s usually the developers maintaining those test list files not the testers.

For this reason I actually prefer and will be recommending the Test Container and Category approach going forward in 2010.  Test Containers are essentially files that contain tests in them.  For example, unit tests (and other compiled tests) are stored in .dll files and ordered tests are in .orderedtest files.  I like this approach.  In automated builds I just want to specify which files contain the tests that I want to run and then if I want to limit the test run to just a subset I can just list which categories to run. 

A great example of this is what I call the “BVT” category.  These are the tests that you have identified to be your “smoke” tests that make sure a build is okay.  If these tests fail then you’ve probably got a bad build.  (BVT = Build Verification Tests) So I would limit the test runs on any CI or even the new Gated Check-In builds to just those BVT tests.  Quick & dirty verification is really all you need for those builds leaving a more extensive automated test pass to happen during the nightly or weekly build.  If you’re not familiar with the new Gated Check-In feature in TFS 2010, check out Brian’s blog post or Patrick’s blog post for more information.  It’s a killer feature.

This does rely on one thing though… each “developer” of an automated test needs to make sure they add the correct attribute(s) to their test methods.  You don’t have to keep up with maintaining the .VSDMI files any longer but you do have to make sure you mark each method appropriately.

You can even use test categories with the new types of automated tests available in 2010 like Coded UI Tests.  It doesn’t just have to be unit tests.

How to Specify a Category in an Automated Test

This part is pretty easy.  You just add as many TestCategory attributes to the test method as you need.  Here’s an example in C# using multiple test categories for a test method called DebitTest:

[TestCategory("Nightly"), TestCategory("Weekly"), TestCategory("Monthly"), TestMethod()]
public void DebitTest()
{
}

Alternately, you can select a test in the Test View tool window and then set the category by using the Properties tool window in Visual Studio and it will add the appropriate attributes to the methods for you.

image

How to Specify which Categories to Run in an Automated Build with Team Build 2010

Okay… this part is easy too. :)  Build definitions now have build properties that can be exposed to the end user in the Build Definition Details dialog or in the Queue Build dialog.  This is handy because you could by default not set a filter to run under normal circumstances (triggered or default manual builds) or you can change it when manually queuing a build if you want that build to run differently.  Either way it’s the same for setting the categories.  If you’re using the default build process workflow that is available out of the box, then just scroll down through the property list until you reach the Testing section which includes a build property called Test Category.  Leave it blank if you want to run all tests or specify the categories you’d like to limit it too:

image image

According to the MSDN documentation for the Test Category switch, you can combine multiple categories in different combinations instead of just specifying one category.  Very handy – here’s some examples:

  • /category:group1 runs tests in the test category "group1".

  • /category:"group1&group2" runs tests that are in both test categories "group1" and "group2." Tests that are only in one of the specified test categories will not be run.

  • /category:"group1|group2" runs tests that are in test category "group1" or "group2". Tests that are in both test categories will also be run.

  • /category:"group1&!group2" runs tests from the test category "group1" that are not in the test category "group2." A test that is in both test category "group1" and "group2" will not be run.

  • What I’m not sure about is whether you can specify test categories when using the old Upgrade Build Workflow template .xaml file… I’ll check on that and then update the blog post.

    It’s worth noting that if you are going to use the test category method to limit test runs, you must use test containers.

    Limiting Test Runs Based on Test Priorities

    If you noticed in the screenshot above from Team Build, you can also limit your test run to tests that are in a specific priority range.  How do you specify the range for your test methods?  You can use the Properties window when selecting a test in the Test View tool window or you can add the Priority attribute manually to the test method.  After that you just specify the range of priorities to use in the test run.

    [TestCategory("Nightly"), TestCategory("Weekly"), TestCategory("Monthly")]
    [TestMethod()]
    [Priority(1)]
    public void DebitTest()
    {
    }

     

    Additional Note:  It appears that the product team is actually encouraging people to move away from the old .VSDMI approach in favor of categories.  Check their note out:

    NoteNote

    Test categories are recommended for use over the test lists functionality from earlier versions of Microsoft Visual Studio Team System Test, unless you have to create a check-in policy which requires a test list. For more information about check-in policies, see How to: Add Check-In Policies.

     

    Take care and happy testing,

    Ed Blankenship

    posted on Friday, September 25, 2009 11:10:32 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Monday, September 21, 2009

    Now this is really cool!  There is a really cool visualization when using Team System Web Access that shows the workflow of the work item that I thought would be really cool if we could have in the Team Explorer client inside Visual Studio.  Well thankfully, Michel Perfetti (author of Fissum) just released a custom work item control that does exactly what TSWA does…

    clip_image002

    Remember, you can have different work item form layouts based on what client it is going to be loaded in so you could specify a layout for “WinForms” that would be the only one that would load this custom control.  Check out Neno’s blog post about this topic for more information.

     

    Check it out on CodePlex:  http://tfsworkflowcontrol.codeplex.com/

     

    Ed Blankenship

    posted on Monday, September 21, 2009 6:39:58 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
    # Wednesday, September 02, 2009

    It’s been a little quiet around here for me because I’ve been in the process of moving to Charleston, SC.  I think I’m settling in well and have a little more time off before I start my new Visual Studio Team System consulting job at Notion Solutions.  So far Charleston and James Island has been really great.  Lots of great stuff to do including restaurants, the beach, and lots of parks.  As much as I love Texas, it’s really good to live in a costal city.

    I just moved into my new homeCharleston Home and if you’ve been following me on Twitter you’ll know that the only thing that has been tough in the new house is the cell phone reception and Wi-Fi signals inside.  If you’ve ever had that problem, you know it can be a real headache.  (If I haven’t called you back it’s probably because I don’t even know that you have called recently :) !)  I really think they put metal mesh or steel plates in the walls and between the floors when they built this house!

    I believe @willia4 says it best:

    image

    The hunt was on to solve this problem and a few friends had suggested a newly available product called zBoost that creates a cell zone inside your home.  I was quite skeptical but after starting to look it seemed to be a realistic possibility.  After visiting the local Radio Shack and not finding it, I decided to look online and found it on Amazon.  A good thing about these products is that they also work with multiple phones & devices inside so you don’t have to worry about it only helping one device at a time.

     

    I spent some time comparison shopping  between buying direct and several online electronic shopping sites and noticed that Amazon had the best deal and about $100 off of retail.  Be careful about which one you order since there are three different models.  Two of the models only work with one set of frequencies but the model I chose is the “dual” frequency model that will work with both spectrums and nearly all the cell phone frequencies in the US.  If you order the single-frequency models you’ll save about $100 on other sites but Amazon had the dual-frequency model for the same price as the single-frequency models!

    Cell-Phone Frequencies

    • PCS 1900 MHz: Sprint and T-Mobile
    • CEL 800 MHz: AT&T and Verizon
    • For more information about the cell phone frequencies used in your area, check out:  Wireless Advisor

    Installation

    So the one thing that you’ll notice immediately (and the only thing I didn’t like about it) is that there are a lot of requirements for the installation to get it working well.

    • To capture the best signal, place the Signal Antenna as high as possible and position it vertically, keeping it at least 2 feet away from any metal.
    • The location of the Signal Antenna should be at least 15 feet higher than the Base Unit Antenna.  (If this is not possible, maximizing the horizontal separation between the two antennas is advised.)
    • If you have extra slack in the cable leftover, don’t let it be near the base unit.  Find the middle point in the line and collect the slack there.
    • Put the base unit closer to the middle of the house and avoid putting it next to an external wall. 
    • Before permanently fastening or bolting the antenna, be sure to check the signal strength in that spot using your cell phone and checking out how many bars you get.  That’s the most you’ll be getting from the cell zone created around the base unit inside.
    • Be sure to use the dedicated coax cable that they provide in the box instead of using the existing coax cabling that may be already installed in your house. For one, the cable provided in the box is RG-6 coax instead of RG-59 coax which is most often used for the TV coax cabling installed in houses.  RG-6 provides lower signal loss than RG-59.  The other more important factor is that you need a dedicated run between the antenna and the base unit so that the signal is not being shared for other things as the TV coax cabling is used in a house.

     

    Attempt #1

    The first attempt was to attach the antenna to a rafter in the attic and then run the coax to the base station in one of the rooms upstairs.  The initial installation check worked out well and the lights on the base unit ended up being happy.  Cell phone reception upstairs was just great.  As I started walking downstairs, I quickly noticed the signal drop very similar to what I had been seeing with my wireless router signal loss downstairs.  I swear there must be some steel plates between the floors that is causing some problems.

    This wasn’t going to work.  At home, I end up spending most of my time downstairs in the living room, master bedroom, kitchen, dining room, etc.

    Attempt #2

    Honestly, just take this route.  It’ll take some more time and possibly put you in some danger but just bite the bullet.  You’ll definitely appreciate the result in the end!

    I decided that the base station needed to go downstairs and probably in the living room where the signal needed to be the strongest since I spend the most time in that room.  So the best solution available was to attach the Signal Antenna to the roof, run the coax cable down the side of the house and then up through the floor of the living room, and put the base unit in the living room closer to the middle of the house.  Thankfully there was already a hole drilled through the living room floor so the cable was just run through it.

    Bingo – the signal was amazing downstairs.  Five bars  in the living room and four bars everywhere else downstairs.  Interestingly, going upstairs now there are three bars.  I don’t know the explanation but I’m just really glad it is all working!

     

    More Powerful Antennas Available

    If you feel the need to turn the juice up, you definitely can with the optional accessories and better antennas available that help you expand the coverage zone to nearly 10,000 feet.  They are available on the Wi-Ex site or through Amazon.

     

    And before anyone thinks that I actually installed this, I’ll just stop now and thank my friends (specifically Nathan) for helping out.  I’m not really the “handy” type of guy so it’s helpful to have friends who are :)  So here’s to five cell phone bars in the living room now…

     

    Take care,

    Ed Blankenship

    posted on Wednesday, September 02, 2009 11:32:07 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback