A big part of the TDD kata I’m doing is running the tests (kinda obvious huh?) and as I’m practicing this mouselessly it is essential that I can invoke my test runner with a keyboard shortcut. My current runner is TestDriven.Net, I’ve been using it for a while and I’m quite happy with it – 3.0 dropped in June so it is being actively developed.
Because I like trying new things, and the tdd kata is a way for me to learn new things, I thought I’d see how the CodeRush Unit Test Runner compared. So after I’d finished with the kata and I had a few tests in my suite I ran them all with TestDriven.Net and the Unit Test Runner.
With TestDriven.Net the tests below total execution time was 1.604 seconds and took 2.24 seconds, not bad, not very fast but not bad. The Unit Test Runner reported a duration of 1.85948165430718 (pretty precise). I’m not sure (and it’s not clear) whether that’s the total execution time, in which case it is quicker than TestDriven.Net or if it’s the total time it was running for, in which case it’s slower than TestDriven.Net. But there is a difference, so giving it the benefit of the doubt I thought I’d try to use the Unit Test Runner instead of TestDriven.Net and see how I got on.
TestDriven.Net can be invoked by pressing the menu key + U, pretty quick though a little awkward to reach the menu key. Alternatively you can bind to any keystroke you want through the Tools > Options > Keyboard settings. Great, now I wanted to find the shortcut I could use to invoke the Unit Test Runner… uhm, nothing is mentioned in the menus and looking in the Keyboard settings I couldn’t figure out what I needed to bind, nothing jumped out at me as an option. So I Googled it for a bit and then went to the DevExpress support system to see what they said. Unfortunately the only post I found, that seemed relevant was Unit Test Runner Window Shortcut which was posted in June and confirmed that there is no shortcut available at the moment – though there are plans to create a shortcut in a future release.
To be honest this is pretty much a deal breaker for me. I’m really happy with just using the keyboard and lifting my hands off just to invoke a test, something I’m supposed to do every minute or so, is really slowing me down. I have to grab the mouse, work out where the cursor is, move the cursor over an icon then click the icon and make a selection (do I want to run the tests or debug the tests) – I know that sounds like a pathetic complaint, but really doing this as frequently as I need to in order to practice TDD is quite painful. Please DevExpress fix this in the very next release!
Update
Didn't think I'd need to update this post this quickly; it's been less than 3 hours and DevExpress have responded to my plea! In 10.1.6 (i.e. the next release) they've added the "ShowUnitTestRunner" action, so you're able to bind any shortcut for opening the Test Runner, which is good news, though I would need to request a daily build or wait for the official release to take advantage.
However Rory Becker has come up trumps with 2 options that you can use today! The first of which is to simply - doh! why didn't I think of that, and the other is a plug-in that shows the test runner
I bound Ctrl+R, Ctrl+T (run tests) to RunSolutionTests and it works great. I will also bind something for RunTestsAtCursor, which are the two I use the most frequently.
My test suite
using System;
using MbUnit.Framework;
using tddKata.Core;
namespace tddKata.Tests
{
[TestFixture]
public class StringCalculatorTests
{
[Test]
public void Add_EmptyString_ReturnsZero()
{
int actual = StringCalculator.Add("");
Assert.AreEqual(0, actual);
}
[Test]
[Row("1", 1)]
[Row("2", 2)]
public void Add_SingleNumber_ReturnsNumber(string numbers, int expected)
{
int actual = StringCalculator.Add(numbers);
Assert.AreEqual(expected, actual);
}
[Test]
[Row("1,2", 3)]
[Row("2,3", 5)]
public void Add_TwoNumbers_ReturnsSumOfNumbers(string numbers, int expected)
{
int actual = StringCalculator.Add(numbers);
Assert.AreEqual(expected, actual);
}
[Test]
[Row("1,2,3", 6)]
[Row("2,3,4", 9)]
public void Add_MultipleNumbers_ReturnsSumOfAllNumbers(string numbers, int expected)
{
int actual = StringCalculator.Add(numbers);
Assert.AreEqual(expected, actual);
}
[Test]
[Row("1\n2,3", 6)]
[Row("1\n2\n3", 6)]
[Row("2\n3,4", 9)]
public void Add_MultipleNumbersNewlineDelimiter_ReturnsSumOfAllNumbers(string numbers, int expected)
{
int actual = StringCalculator.Add(numbers);
Assert.AreEqual(expected, actual);
}
}
}
ad188aaa-9a45-449c-86e9-3a2dd380d2d1|1|4.0
Permalink |
Comments (3)