MorningLightMountain

a little something from an immotile

Archive for November, 2011

Timing integration tests

Posted by Dan G on November 30, 2011

Once more Fluent Assertions has come in handy for providing a simple way of asserting the execution time of an Action (in this case a big bit of data formatting), buried away almost as foot note on their docs page is:

New in version 1.4 is a method to assert that the execution time of particular method or action does not exceed a predefined value. To verify the execution time of a method, use the following syntax:

var subject = new SomePotentiallyVerySlowClass();
subject.ExecutionTimeOf(s => s.ExpensiveMethod()).ShouldNotExceed(500.Milliseconds());


Alternatively, to verify the execution time of an arbitrary action, use this syntax:

Action someAction = () => Thread.Sleep(510);
someAction.ExecutionTime().ShouldNotExceed(100.Milliseconds());


Since it doesn’t make sense to do something like that in Silverlight, it is only available in the .NET 3.5 and .NET 4.0 versions of Fluent Assertions.

Make sure to set a sensible execution limit – bear in mind who’s running the tests (might be slow hardware – false negatives ahoy). It’s considered polite to put a Category attribute with a “Slow” value so people can exclude long running integration tests.

Posted in Tools | Tagged: , , , | Leave a Comment »

Laziness, Impatience and Hubris

Posted by Dan G on November 29, 2011

The qualities you will always find in great software engineers, http://threevirtues.com/. However you should be very careful around hubris…

Posted in Other | Tagged: | Leave a Comment »

Deep MSBuild with Powershell

Posted by Dan G on November 24, 2011

I’ve been working with Powershell on and off for a while now and wanted a tool to do a search through a directory (a single pull of a VCS repository) find all .sln files and build them all with MSBuild and report the results:

param([string]$rootPath)

$sln_files = Get-ChildItem -Filter *.sln -Recurse -Path $rootPath

$fails = @{}
$passes = @{}

foreach($sln in $sln_files)
{
    try
    {
        $sln.FullName
        $clean = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe """ + $sln.FullName + """ /t:Clean /m"

        Write-Host $clean

        Invoke-Expression $clean
        $build = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe """ + $sln.FullName + """ /t:Build /m"

        Write-Host $build

        Invoke-Expression $build

        if($LastExitCode -ne 0)
        {
            Write-Host "########## FAIL ########"
            $fails.Add($sln.Fullname,$sln)
        }else
        {
            Write-Host "########## PASS ########"
            $passes.Add($sln.FullName,$sln)
        }

    }
    catch
    {
        $fails.Add($sln.FullName,$sln)
    }
}

Write-Host $fails.Count Failed
Write-Host $passes.Count Passed

Write-Host "FAILS"
$fails
Write-Host "PASSES"
$passes


I just set it off against a big pile o’ code (some gnarly, some clean) and the results are pretty much as I expected.

Posted in Tools | Tagged: , | Leave a Comment »

Venn diagrams for logic gates

Posted by Dan G on November 24, 2011

On the Wikipedia page for Logic Gates there’s a picutre of the sequence of  logic statements / gates illustrated as venn diagrams created by ZanderSchubert. Starting from false (completely empty) a range of gates are applied against a pair of inputs finally reaching true (completely filled).

Logic Gates in Venn Diagram form

 

Posted in Other | Tagged: , | Leave a Comment »

A child of five…

Posted by Dan G on November 22, 2011

“A child of five would understand this. Send someone to fetch a child of five.”

Groucho Marx

Some of the rules about computers and systems are so fundamental that a child of five (in this case, rather fortuitously, Loki) can understand it and extrapolate extra rules (or scenarios).

Starting from two statements:

  • A computer can only do what it’s told to do, by humans
  • Computers don’t make mistakes, humans do

He was very quickly able to reach these conclusions:

  • A computer can’t do what it’s not been told to do
  • If a computer makes a mistake, it’s because a human made a mistake

He doesn’t quite understand the nuance of how many humans could have made the mistake (he only considers the user at the moment, not the pile of software engineers / QA / project managers / etc hidden behind the curtains), but the seed is there.

Pedants may now bang on about hardware failure ;)

Posted in Family | Tagged: , | Leave a Comment »

Lerryns latest posts

Posted by Dan G on November 22, 2011

Lerryn’s just updated her blog with instructions for making Sock Monkeys and “knitting” with plastic bags – Jelly Bean Boom

Posted in Family | Tagged: | Leave a Comment »

Never say Never again…

Posted by Dan G on November 21, 2011

It’s one of those tricky subjects, you’ll get asked if you prefer code Arrangement A or Arrangement X. You might reply that in general you prefer Arrangement X for Reason D and dislike Arrangement A for Reason C. However, make damn sure you NEVER say NEVER use Arrangement A or Arrangement B because of my personal Reason D / C.  You might not have encountered a particular case in which Arrangement A is vastly superior to Arrangement B, or a scenario in which the performance of Arrangement A rapidly degrades. You can’t know it all, and you never will.

There are plenty of times that something really is a NEVER do that (like say Locking another mans Type or Reading the Stream.Read fine print) but those aren’t preferences. They’re hard factual instances where something will break if you keep doing it that way.

Your reasons for a choice are your own, they’re never someone elses reason, and that someone else will have different reasons for doing it the way they are. Respecting different opinions is vital!

Posted in Good practie | Leave a Comment »

Excellent post by Eric Lippert on Why IL?

Posted by Dan G on November 20, 2011

Eric Lippert has put together an excellent blog post called Why IL that explores the reasoning behind having an Intermediary Language rather than going straight to the bytecode from the source compiler.

Posted in Other | Tagged: , | Leave a Comment »

Jack – the robot that Loki (and Lerryn) built

Posted by Dan G on November 19, 2011

Lerryn visited the new Poole location for Dorset scrapstore on Friday (New location for Dorset Scrapstore in Poole), and thought our son Loki would enjoy a visit, maybe getting materials to build a robot with. She described the store to him and his immediate reaction was – build a robot (one track mind) so we visited on Saturday. He loved it and was picking things out left, right and center, imaging what part it could be, how many he’d need. Lerryn suggested the more structural pieces he’d really need and one of the fab assistants found a long length of  coiled foil air ducting.

With suitable materials they set to work, Loki dictating the design whilst Lerryn guided him in terms of what would actually work. He’d apparently already worked out how to do the hands when we were in the store – making sure to get exactly ten of the pieces of tubing he’d picked for fingers.

Loki made sure to get exactly the right number of fingers

Posted in Family | Tagged: , , | Leave a Comment »

Continuous Integration with Team City

Posted by Dan G on November 15, 2011

Wherever possible I like to work with a Continuous Integration pattern both solo and in a team (if working solo it adds an extra level of discipline), and have over the past used a variety of Automated CI platforms for .NET, ranging from CruiseControl.Net from Thoughtworks, through TFSBuild (worst ACI ever I’m afraid Microsoft) before finally settling on Team City from Jetbrains (makers of Resharper). Even better it’s FREE (with a limit (?) of 3 build agents and 20 build types per server, any server… for free). Setting up simple CI builds of a branch from pretty much any VCS is straightforward, and all of practices described by Martin Fowler that can help structure ACIs are possible.

Out of the box, TeamCity will give you runners for (in a .NET environment):

MSBuild, NAnt, NUnit (with code coverage from dotCover, free), StyleCop, FxCop, Duplication analysis and MSTest.

Builds can be triggered on a variety of criteria: commits, date/time, frequency and other builds completing,.

Note the MSBuild runner – primarily you’ll want it for compiling your code, but MSBuild is a useful extension point for more complex build types. Imagine a build that can push itself into a test environment ready for user feedback with no human hand touching it (and screwing it up).

Posted in Good practie, Other | Tagged: , , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 165 other followers