Debugging speed of Gallio fixtures – reloaded

March 25, 2009 at 10:19 PMAndre Loker

Last week I mentioned the slow debugging of Gallio unit tests. After having published that blog post I had a conversation with Jeff Brown about this issue. After showing him in a video how huge the difference in speed between debugging an MbUnit 2.4 and an MbUnit 3 test was he pointed out that this might have to do with the fact that MbUnit 2.4 uses the multi threaded apartment state (MTA) per default, while MbUnit 3 uses single threaded apartment state (STA).

I tested this difference by debugging the test fixture shown below:

   1: [TestFixture]
   2: public class CalculatorTests {
   4:   [Test, ApartmentState(ApartmentState.STA)]
   5:   public void Adding2And3ShouldReturn5_STA() {
   6:     TheTest();
   7:   }
   9:   [Test, ApartmentState(ApartmentState.MTA)]
  10:   public void Adding2And3ShouldReturn5_MTA() {
  11:     TheTest();
  12:   }
  14:   void TheTest() {
  15:     var x = 2;
  16:     var y = 3;
  17:     var expected = x + y;
  18:     var sut = new Calculator();
  19:     var actual = sut.Add(x, y);
  20:     Assert.AreEqual(expected, actual);
  21:     MessageBox.Show("END OF TEST!");
  22:   }
  23: }

And indeed: the STA unit test ran sluggish as reported while the MTA based unit test could be debugged at virtually the same speed as I am used to from MbUnit 2.4 tests.

I reported that back to Jeff and he proposed to change the default thread apartment state to MTA with the option to override this default using an assembly scoped attribute (for unit tests that require STA).

Thumbs up to Jeff!


Jeff reported that after some further research the solution to the problem might not be as simple as this and he needs to think it over. Anyway, I’m glad to see that this issue is being worked on.

Posted in: Tools

Tags: ,

Pingbacks and trackbacks (1)+