Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

MbUnit DependsOn attribute seems to be ignored
espenalb
#1 Posted : Wednesday, March 28, 2012 4:46:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/28/2012(UTC)
Posts: 1
Location: Florø

Thanks: 1 times
I recently discovered nCrunch - and I am impressed, and feel it greatly improves my TDD!

However, I got one problem - when nCrunch tries to execute a test I have written that uses the MbUnit "DependsOn" feature. I use this feature in a test where I test "Normal usage" - and this testfixture requires each test to be executed in the correct order.

Here is a sample that passes in Gallio, but fails in nCrunch:
Code:

    [TestFixture]
    public class DependsOnTest
    {
        private String _state = "";
        [Test(Order = 0)]
        public void First()
        {
            Assert.AreEqual("", _state);
            _state = "First";
        }

        [Test(Order = 1)]
        [DependsOn("First")]
        public void Second()
        {
            Assert.AreEqual("First", _state);
            _state = "Second";
        }

        [Test(Order = 2)]
        [DependsOn("Second")]
        public void Third()
        {
            Assert.AreEqual("Second", _state);
            _state = "Third";
        }


Is this a known bug? I read in another post that nCrunch uses Gallio under the hood - but looks like it does not behave 100%....
Remco
#2 Posted : Wednesday, March 28, 2012 8:35:21 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Hi, thanks for posting! I'm glad your enjoying NCrunch!

I can understand why the 'DependsOn' attribute would have some problems. NCrunch separates tests into batches before running them, in order to provide the best experience with parallel execution. It's possible that the tests are being separated from each other into different batches and this is changing the sequence in which they are run.

I'll note this issue down for a future fix. Meanwhile, you may be able to reduce the fragility of the tests by marking the entire fixture with the 'NCrunch.Framework.Isolated' attribute. This will encourage NCrunch to pipeline the tests together and will reduce the risk of them being separated at runtime. You can find more information about this attribute in this wiki at http://wiki.ncrunch.net/IsolatedAttribute.ashx
1 user thanked Remco for this useful post.
espenalb on 3/28/2012(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.024 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download