Recent posts

Slides and demo code for my TDD/SOLID talk at DevDays 2009

Even though it was just a wildcard session (people had to vote for my proposal), the room had a capacity of only 50 people, and the DevDays organization forgot to list the wildcard sessions on the website, I was very happy to see that the room was more than full. Although I had quite a lot of content to cover and the pace of my session was quite high, I think it went very smooth. Since it is not possible to fill-in an evaluation form through the DevDays site, hopefully, people drop me an email or a tweet me with some feedback.

Anyhow, in case you want to review the slides or inspect the code I’ve used to create the demos and examples, get the slides from here, and the code from here.


Published: 01-06-2009 by Dennis Doomen | 0 Comments | 0 Links to this post
 

Almost missed it but VSTS2010 beta1 is available for download!

Are you curious? I am, so what are you waiting for go to your msdn subscription and download VSTS2010 beta1; I am already installing ;-).


Published: 20-05-2009 by Hans ter Wal | 0 Comments | 0 Links to this post
 

I’ll be speaking at the Microsoft Developer Days 2009

Thanks to the many votes we received on our wildcard proposals from attendees, colleagues and community members, me, Pieter Joost van de Sande and Dennis van de Stelt have won a timeslot on next week’s Microsoft Developer Days. I’ll be talking about Test Driven Development and SOLID on Thursday May 28th at 15:00 in the conference room named Central America.

Many attempts have been made to improve the overall quality of our software development efforts, but if there's one I'd like to put some attention on, it's Test Driven Development. It's design-first, test-first approach has proved significant increases in overall quality. However, TDD is not easy and requires quite some understanding of proper object oriented design. S.O.L.I.D. is one of the better known acronyms referring to a set of very important design principles that both improve your ability to do TDD, but also make sure that your software is highly testable and maintainable.

Stuff I’ll be covering:

  • What is quality?
  • Demonstrating Test Driven Development with a hands-on demo
  • The S.O.L.I.D. principles
  • Phases of unit testing
  • Examples illustrating the advantages of S.O.L.I.D.
  • Guidelines for getting started

Prerequisites: You should be able to understand C# 3.0 and Lambda expressions, and feel at home amongst the principles of OO such as encapsulation, inheritance and polymorphism.

In the mean time, if you like to follow me on my daily activities until the DevDays, my Twitter account is http://twitter.com/dennisdoomen


Published: 19-05-2009 by Dennis Doomen | 0 Comments | 0 Links to this post
 

Try to do this without LINQ

Today, me and my colleague Cor have been busy pair-programming for most of the day. While doing that we tried to build a dictionary which value is an enumerable collection. I think we found a great example of the power of LINQ that I think is worth sharing.

Consider the class diagram below. ExamSeries represents a examination series consisting of one or more questions. Each series has a language-specific part represented by SeriesDetail. Our goal was to be able to apply a Specification object to a collection of ExamSeries and receive a dictionary of all series matching that specification, including the specific languages. So our intention was to get a IDictionary<ExamSeries, IEnumerable<Language>>.

image

We started hand-writing multiple foreach loops and managed to get what we wanted, but somehow, I got this annoying feeling in the back of my head that this should be easier. After a lot of experimenting, we found the following rather nice example of using LINQ.

image

Not bad eh?


Published: 18-05-2009 by Dennis Doomen | 0 Comments | 0 Links to this post
 

Acceptance based testing tools

I really like the idea of having executable specifications. They can be used as requirements documentation and describe what your stakeholder expects from the software. Besides that, it is also useful as an indication of the progress being made by the development team. But what tools are there for automating acceptance tests?

Fitnesse

One of the most commonly used tools is Fitnesse. This is a wiki in which the tests can be described as tables. These tests can be described by the stakeholder and be mapped to test drivers that are created by the developers. A test driver is a mapping of the acceptance test to the code that needs to be tested, thus making the test executable.

There also is an extension to Fitnesse called Webtest. This actually is a generic test driver for mapping Fitnesse tests to Selenium scripts. If you are not familiar with Selenium, Selenium is a tool for testing web applications. For example, in c# a Selenium script looks like the following:

ISelenium sel = new DefaultSelenium(
"localhost", 4444, "*firefox", "http://www.google.com");
sel.Start();
sel.Open("http://www.google.com/");
sel.Type("q", "FitNesse");
sel.Click("btnG");
sel.WaitForPageToLoad("3000");

The webtest extension for Fitnesse allows you to write acceptance tests like the following:

image

The test can then be executed from within the browser, which results in:

image

So this is really cool, I really like the ability for the customer to open the tests via a browser and run the tests from the browser. But there are some things about Fitnesse that I don’t really like. As far as I know there is no source control integration and there is some friction in writing the test drivers. Writing the web tests is easy, but sometimes you need to test different functionality, which requires writing custom test drivers / fixtures. Some of these fixtures can become really cumbersome and complex. Besides that, I also think the tests still contain to much technical details. The organization of the tests (think test suites) and also the definition of the tests still contain technical details and are pretty fragile. The customer can easily break the tests. So overall, I really like the fitnesse approach, but there are some shortcomings. So are there any alternatives?

StoryTeller

StoryTeller is a replacement for Fitnesse. The first version of StoryTeller was based on the Fitnesse test engine, but the creator ran into a wall with the Fitnesse test engine. So he decided to reboot the StoryTeller project from scratch and created his own test engine. The progress looks promising, but the project is still very fresh. I’m eagerly following its progress, but to me it looks to immature to be used in a real live project at the moment. However, its creator Jeremy Miller, is a respectable member in the .NET community with an impressive track record, so I would definitely keep my eye on this one.

Twist

Thoughtworks offers a commercial product called Twist, which really is the way to go in my opinion. The user has it’s own user interface for defining the user stories in its purest form. The developers can then map these stories to executable tests from their own development environment. I really like the way this separates  concerns. However the product uses Eclipse as a host IDE and the test drivers can only be written in java, which is not an option to me. Now what to use?

What to use

In my opinion, Twist provides the best experience to the end user and makes it really easy for developers to write the test drivers. If twist were to be integrated into visual studio and provided the ability to write test drivers in .NET, I would probably go for Twist. Unfortunately, this is not the case.

I’m also really interested in which way StoryTeller is going. Jeremy Miller just released a sneak preview, but it does not provide any information about how the user will be defining the tests. I hope it will be anything like Twist.

For now, despite its shortcomings, I’m going to continue my work with Fitnesse, because it simply is the most widely used and mature tool out there.  However, I’m keeping my eyes open for alternatives. 


Published: 12-05-2009 by Jonne Kats | 0 Comments | 0 Links to this post
 

TFS: Getting all Checked Out files via TF.exe

Edit 13 may 2009 : There is another good alternative. One of my friendly colleagues pointed out  to me you can also install the latest TFS  Power Tools (October 2008).

You will then have a nice UI  with some new features. Some of those features are:
1) “Find in Source Control Explorer”.
It’s possible to show the current checkout status in any folder in Source Control Explorer.
2) A new “Team Member” node in Team Explorer.
For each member you can see for example the “check-in history” or “Pending changes”.

------------------------------------------------------------------------------------------------------------------

When you are working with Team Foundation Server (TFS), sometimes you require an overview of all Checked Out files. For example, you want to be sure your colleague can go on holiday after he/she finished his/her work with a mandatory check-in.

I was unable to see all Checked Out files by any user with Team Explorer, so I started looking at the command line tool TF.exe. After that, it was really simple to get an overview.  You can even integrated the command line tool in Visual Studio. You just add a new "External Tool".

 

First, the TF.exe command line tool:

The location of the command line tool:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\tf.exe

To change/add a local workspace:
tf.exe workspace

All checked out files in $/FavoriteProject:
tf.exe status $/FavoriteProject /user:* /recursive

All files checked out to Tim:
tf.exe status /user:Tim

All checked out files in $/FavoriteProject using Login Credentials:
tf.exe status $/FavoriteProject /user:* /recursive /login:yourDomain\tim,yourdomainpassword

------------------------------------------------------------------------------------------------------------------

Second, a  short walk-through to use the tf.exe command in Visual Studio IDE.

  • - Select from the menu: "Tools / External Tools ..."
  • - In the "External Tools" dialog, click the "Add" button.
  • - Enter a title that will show up in the Tools menu (ie. "Show FavoriteProject Checkouts")
  • - Enter "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\tf.exe" for the command
  • - Enter "status $/FavoriteProject /user:* /recursive for the arguments.
  • - Make sure that the "Use Output Window" check-box is checked.
  • - Make sure that the "Prompt for Arguments" check box is checked. (Optional, if you want to use login-credentials)
  • - Click OK to save.
  • - You can now execute the tool from the menu. The output will be shown in the output window.

example_tf


Published: 12-05-2009 by Tim van der Weijde | 0 Comments | 0 Links to this post
 

Integrate xUnit tests into your daily Team Build

Doing proper Test Driven Development with the default visual studio test runner (mstest) is like playing Gears of War 2 on an old fashioned tube television, it’s just wrong ;).. There are several alternatives out there like mbUnit and nUnit, but my favorite is xUnit. xUnit is heavily extensible and there is a project called xunitbddextensions, which extends xunit making it possible to do specication based testing (BDD). Using resharper or testdriven.net this makes for an excellent experience when developing in visual studio. xUnit tests can also be integrated into your daily TFS (Microsoft Team Foundation Server) build by using the xUnit build task. However, the details of the testresults are not displayed in the build overview and the results are not used in the reporting functionality of TFS (Like the Quality Indicators report).

On the xUnit site there is some discussion about this functionality, but at the moment there is no implementation. For nUnit there is a project on codeplex called nUnit for Team Build. This consists of a sample build script that uses an XSLT file to translate the xml results of nUnit into a visual studio test result file and publishes this result to TFS. This way integrating the nUnit test results into TFS.

I figured I could modify the XSLT file to translate the xUnit tests results instead. However, having a better look at the xUnit build task I noticed a NunitXml property, which makes it possible to output the xUnit results into a nUnit compatible xml file.  So I could just use the XSLT file and integrate the xUnit results into our TFS build.

To make this work I only had to modify the build script to use the xUnit build task instead of  the nUnit build task. This resulted in the following script (This just needs to be added to the end of your build definition):

  <!-- Xunit Build task-->
  <PropertyGroup>
    <XunitBuildTaskPath>$(ProgramFiles)\MSBuild\Xunit\</XunitBuildTaskPath>
  </PropertyGroup>

  <UsingTask AssemblyFile="$(XunitBuildTaskPath)\xunit.runner.msbuild.dll"
    TaskName="Xunit.Runner.MSBuild.xunit"/>

  <Target Name="AfterCompile">
    <!-- Create a Custom Build Step -->
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Name="XUnitTestStep" Message="Running Xunit Tests">
      <Output TaskParameter="Id" PropertyName="XUnitStepId" />
    </BuildStep>

    <CreateItem Include="$(OutDir)\*.Test.dll">
      <Output TaskParameter="Include" ItemName="TestAssemblies"/>
    </CreateItem>

    <!-- Run the tests -->
    <xunit ContinueOnError="true" Assembly="@(TestAssemblies)" NUnitXml="$(OutDir)nunit_results.xml">
      <Output TaskParameter="ExitCode" PropertyName="XUnitResult" />
    </xunit>

    <!-- Set the status of the buildstep in the build overview -->
    <BuildStep Condition="'$(XUnitResult)'=='0'" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(XUnitStepId)" Status="Succeeded" />
    <BuildStep Condition="'$(XUnitResult)'!='0'" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(XUnitStepId)" Status="Failed" />

    <!-- Regardless of NUnit success/failure merge results into the build -->
    <Exec Command="&quot;$(XunitBuildTaskPath)\nxslt3.exe&quot; &quot;$(OutDir)nunit_results.xml&quot; &quot;$(XunitBuildTaskPath)\nunit transform.xslt&quot; -o &quot;$(OutDir)xunit_results.trx&quot;"/>
    <Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe&quot; /publish:$(TeamFoundationServerUrl) /publishbuild:&quot;$(BuildNumber)&quot; /publishresultsfile:&quot;$(OutDir)xunit_results.trx&quot; /teamproject:&quot;$(TeamProject)&quot; /platform:&quot;%(ConfigurationToBuild.PlatformToBuild)&quot; /flavor:&quot;%(ConfigurationToBuild.FlavorToBuild)&quot;"/>
    
    <Error Condition="'$(XUnitResult)'!='0'" Text="XUnit Tests Failed" />
  </Target>

This script assumes you have copied the xunit  build task, the XSLT file and the nxslt3.exe file to a \MSBuild\Xunit\ folder under the program files folder on your build server.

Whether the tests fail or not, the resuls should always be published. However, the xUnit build task does not have an ExitCode and I could not find another way to get the result from the xUnit task. So I have modified the xUnit task to provide an ExitCode. Open up the xUnit code from codeplex. Locate the xunit.runner.msbuild project and open up the xUnit class. Add the following property and modify the Excute method to modify the value:

        [Output]
        public int ExitCode { get; private set; }

        public override bool Execute()
        {
            try
            {
                string assemblyFilename = Assembly.GetMetadata("FullPath");

                if (WorkingFolder != null)
                    Directory.SetCurrentDirectory(WorkingFolder);

                using (ExecutorWrapper wrapper = new ExecutorWrapper(assemblyFilename, ConfigFile, ShadowCopy))
                {
                    Log.LogMessage(MessageImportance.High, "xUnit.net MSBuild runner (xunit.dll version {0})", wrapper.XunitVersion);
                    Log.LogMessage(MessageImportance.High, "Test assembly: {0}", assemblyFilename);

                    IRunnerLogger logger =
                        TeamCity ? (IRunnerLogger)new TeamCityLogger(Log) :
                        Verbose ? new VerboseLogger(Log) :
                        new StandardLogger(Log);

                    List<IResultXmlTransform> transforms = new List<IResultXmlTransform>();

                    using (Stream htmlStream = ResourceStream("HTML.xslt"))
                    using (Stream nunitStream = ResourceStream("NUnitXml.xslt"))
                    {
                        if (Xml != null)
                            transforms.Add(new NullTransformer(Xml.GetMetadata("FullPath")));
                        if (Html != null)
                            transforms.Add(new XslStreamTransformer(htmlStream, Html.GetMetadata("FullPath"), "HTML"));
                        if (NUnitXml != null)
                            transforms.Add(new XslStreamTransformer(nunitStream, NUnitXml.GetMetadata("FullPath"), "NUnit XML"));

                        TestRunner runner = new TestRunner(wrapper, logger);
                        if(runner.RunAssembly(transforms) == TestRunnerResult.Failed)
                        {
                            ExitCode = -1;
                            return false;   
                        }

                        ExitCode = 0;
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                Exception e = ex;

                while (e != null)
                {
                    Log.LogError(e.GetType().FullName + ": " + e.Message);

                    foreach (string stackLine in e.StackTrace.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                        Log.LogError(stackLine);

                    e = e.InnerException;
                }

                ExitCode = -1;

                return false;
            }
        }

Now build the project and deploy the xUnit build task to the server. To realize the xUnit build integration just follow the steps you find on the nunit4teambuild site and use the previous mentioned modifications. After this, you should be set to go.

BTW: In the nunit4teambuild they use nxslt2, I used nxslt3. So depending on which one you use, modify the script accordingly.


Published: 07-05-2009 by Jonne Kats | 0 Comments | 0 Links to this post
 

About Programmer Lifestyle Dilemmas

image

Yesterday, I attended the second Devnology meeting in Utrecht and I had a really fun evening. Devnology is an initiative started by Pieter Joost van de Sande and Freek Leemhuis and focuses on sharing experiences, insights and knowledge between members of the entire developer community. That means that you'll see not only .NET and Java developers, but also developers using C++, Ruby on Rails, SmallTalk and even functional programming. It felt very refreshing to hear about all those other platforms I simply don't have the time for.

This session was held in one of the very attractive rooms offered by Seats2Meet in Utrecht and focused on the typical dilemmas a programmer has to face in his daily duties. As a kind of preparation we were asked to answer a list of questions related to our habits, interests and so on. I thought it would be nice to share my answers and also mention the things I heard from the others and will read or investigate.

Q: Do you prefer to work as an independent consultant or be on someone’s payroll?
I have always liked to work for a company, either big or small, as long as they can offer enough interesting opportunities. I don't like to find my own customers (at least, not initially) or spend time on administrative tasks. Moreover, working in a company offers my changes for sharing knowledge, experiences and enthusiasm.

Q: Do you prefer to work in pairs or alone?
I definitely stimulate Pair Programming within my teams since I've seen it cause an improvement in the overall level of technical and domain knowledge. But I myself don't always do it, mostly, because I typically have a lot of team leading tasks. The primary reason for me to sit next to another developer is to improve the usage of coding guideline, design principles and other best practices. Obviously, when trying to figure out a complex technical challenge, Pair Programming really excels.

Q: Do you prefer to work in the office or at home?
I prefer to work at the office since it is more fun, and allows me to have interesting discussions with other colleagues.

Q: Can you live with a waterfall methodology or do you insist on Agile?
I have lost faith in a traditional waterfall approach, and strongly believe in many of the aspects of typical Agile methodologies. I'm currently looking into using (elements of) SCRUM for my projects.

Q: Do you try to keep up with all the latest developments, or focus on concepts?
I always try to stay in shape by reading blogs, books and by having discussions with other members of the community. However, I'm starting to become aware of the fact that I can't keep up that pace for a very long time. As a matter of fact, I'm already pushing some of the newer technologies that are not yet necessary for my current tasks aside as long as possible.

Q: Specializing or generalizing
I focus my attention on the stuff that helps me the most at my current job, but I do have a particular interest in Test Driven Development, design and architecture. However, I always keep an overview of all the products and technologies the Microsoft platforms offers. So, I'm both :-)

Q: What are your three favorite blogs?

Q: What are your three favorite Podcasts?
I've never done that, but looking at the popularity of these during this meeting, I'm going to look into them.

Q: Name three books that had a lot of impact

  1. Applying Domain Driven Design and Patterns - Jimmy Nillson
  2. Domain Driven Design: Tackling Complexity in the Heart of Software - Eric Evans
  3. Scrum and XP from the Trenches - Henrik Kniberg

Q: What tools do you use to find knowledge?
I primarily use Google Reader to stay up to date with a whole bunch of blogs. I don't understand why Microsoft's Live site does not provide something like this.

Q: What events do you visit regularly?
PDC or Teched, Microsoft Developer Days, Software Developer Event / Conference, CodeCamp, DotNed, Devnology, OpenSpace

Q: What are you going to read or investigate as a result of this second Devnology meeting?


Published: 07-05-2009 by Dennis Doomen | 0 Comments | 0 Links to this post