RSS
 

Archive for the ‘Testing’ Category

Introducing Power Assert .NET

12 Nov

I’ve just released a new open source project on codeplex: http://powerassert.codeplex.com

Power Assert .NET is a .NET port of Groovy’s PowerAssert, which replaces your normal unit test assertions.

Unlike the standard assertions built into nunit, MSTest, and xunit etc; Power Assert gives you a breakdown of all the values within your assertion expression, making it quicker for you to hunt down the cause of the test failure:

System.Exception : IsTrue failed, expression was:
x + 5 == d.Month * y
| | | | | | |
| | | | | | 6
| | | | | 18
| | | | 3
| | | 01/03/2010 00:00:00
| | False
| 16
11

It’s quite a simple little thing, but it’s already saved me lots of debugging time. Give it a go :)

 
1 Comment

Posted in .Net, Testing

 

The new StoryQ

22 Jun

I was recently interviewed for a podcast about my Behaviour Driven Development framework, StoryQ. David Starr from Pluralsight did a great job with the interview – check it out at www.pluralsight-training.net/community/blogs/pluralcast/archive/2010/06/21/pluralcast-18-bdd-in-net-with-storyq.aspx.

David also gave a great presentation on BDD at the 2010 tech ed in New Orleans, and I highly recommend it for anyone wondering how to get started, or even whether they should get started, with BDD: http://www.msteched.com/2010/NorthAmerica/DPR302

Improvements

I think this is a good opportunity to talk about some of the new features in StoryQ. My first post on StoryQ came when we’d just committed it to codeplex, and a lot has changed since then:

  • We’ve moved to Mercurial, which means our users can create public forks
  • No more ()=> operator. Thanks to FLIT, our fluent interface has evolved to accept plain old delegates, instead of Expression<Action>s.
  • Tagging. Any Step can be “tagged”, which makes it easy to find in the output report
  • By default, the HTML report generated by StoryQ is JQuery-enriched, which makes it easy to narrow down stories by class hierarchy or tag. I’m particularly proud of this report – it’s a great way to share test results with everybody, especially when published from a continuous integration server.
  • A rewritten converter gui, which lets you convert plain text stories into StoryQ code. The new version lets you choose what level of code generation you want (from Story initialisation statement to entire test class), and offers a basic form of intellisense.

Roadmap

  • The new fluent interface architecture allows us to support multiple (human) languages, and I’m looking forward to creating fluent interfaces for non-english speakers.
  • I think we’ll be able to create a new way of doing BDD in .NET that takes advantage of C# 4.0′s dynamic features
  • We still haven’t added xUnit support! Which is lame, because it’s probably going to be really easy…

Please check StoryQ out and let us know if you’ve got any bright ideas for it! And if you’ve never tried BDD, you should definitely look into it. It’s even more fun than TDD!!!

 
No Comments

Posted in Me, StoryQ

 

Building Dependable code with Dependency Injection – Slides & Source

02 Sep

Here are my slides and the source code to the TDD & DI talk I gave at CodeCamp Auckland 2008. My intent with the talk was to explain how TDD can be really good, and how DI can make TDD easier.

If you weren’t at my talk and have any questions – I’m in the market for more comments.

I’ve got one more link to add, these podcasts were what actually inspired my subject: http://channel9.msdn.com/shows/ARCast+with+Ron+Jacobs/ARCastnet-Presenter-First-Pattern-Part-1/

Here is my source code (perfectly commented), and here are my slides

Stay tuned for a bigger (50 line) do-it-yourself DI container that would be useful in production.

 
4 Comments

Posted in .Net, Testing

 

Bridging Unit Test Frameworks with Gallio

23 Aug

Update: Jetbrains have just released Resharper 4.5, which contains native MSTest support. No need to read the rest of this article, then!

Read the rest of this entry »

 
6 Comments

Posted in Testing

 

StoryQ: BDD / Acceptance Testing with a little help from LINQ

24 Jul

My first ever “write” operation to the Open Source community just happened! Todd (who I am working with at Datacom) was really keen to start using NBehave. He wanted to provide our clients with more visibility of what features were implemented / broken in each release. Because we were releasing every time someone checked in some code, it was pretty important to automate this.

NBehave, much like ruby’s rspec, is a great framework for making user stories executable within your IDE. Outside of your IDE, you’ve got things like Fitnesse, ZiBreve, and Twist - which are better if you want non technical people to be able to interactively define storys. On our project, however, we had technical people putting the acceptance tests into our Nunit project. Now, NBehave is written as an extension to NUnit, so i guess you could say they are compatible, but NBehave wasn’t compatible with the two NUnit runners that we were using all the time. Our developers used the superb Resharper test unit runner as they coded, and our build server (TeamCity, damn you JetBrains!) both wanted to run plain old NUnit.Framework.TestAttribute Tests.

So we set out to create a simple framework for running things that looked like story tests from within any test framework. StoryQ is what Todd & I came up with. The key points of difference from NBehave are:

  • No dependency on any particular unit testing framework (although StoryQ does like to know what kind of Inconclusive / Pending exception your framework uses)
  • StoryQ can use Lambda Expressions to make a sentence-like string out of a method call. This might not sound like much, but it actually takes away a lot of duplication pain. Thanks, LINQ!
  • When you run a brand new story test, it will be marked as pending (not failed).
  • By default, StoryQ output goes to Console.Out. You can also make it write a coloured html report to a file.
  • There is a GUI in the project that can convert from plain text into test case code.

We’ve tried to keep it all very simple and lightweight. If you feel like your current acceptance testing framework is too clunky, or if any of the benefits above sound good to you, then please grab the code and check out the samples. There’s an explanation up on the project homepage. We are very keen for feedback: issues, comments, feature requests, contributors – please don’t hold back.

 
16 Comments

Posted in StoryQ