MorningLightMountain

a little something from an immotile

Archive for the ‘Tools’ Category

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 »

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 »

Resharper Live Templates & More on GitHub

Posted by Dan G on November 9, 2011

One last thing tonight, I’ve started storing my own Resharper Live Templates in a public repo on my GitHub account. They’re broken up by category into individual files so they’re a bit easier to manage, though all, I’m afraid, for C#.

I’ve also put up a small demo app that I built whilst working with @annie_watkins showing how Structure Map can be used by WCF to inject dependencies into services, as well as why dependency inversion is a good thing with mocked unit tests. I’m might do a quick article on it in the near future.

Finally I’ve made progress with the branch of RHAL9000 (imaginatively titled  Rebuild_1) where I’m seperating the source of the data and their synchronization away from the view models and the ultimately the UI. Hopefully more on this project soon.

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

 
Follow

Get every new post delivered to your Inbox.

Join 165 other followers