chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
here's the test code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MbUnit.Framework;
using TypeMock.ArrangeActAssert;
using TypeMock;

namespace MBUnitProblem
{
    [TestFixture, ClearMocks]
    public class BaseFixture
    {
        protected int count;
        [FixtureSetUp]
        public void FixtureSetUp()
        {
          
        }

        [SetUp]
        public virtual void SetUp()
        {
            

        }

        [TearDown]
        public void Clean()
        {
            count = 0;
        }



    }

    public class DerivedFixture : BaseFixture
    {

        public override void SetUp()
        {
            base.SetUp();
            count++;
            Assert.AreEqual<int>(1, count);
        }

        [Test, Isolated]
        public void test1()
        {
        }

        [Test, Isolated]
        public void test2()
        {
        }
    }
}



You will get two failures
TestCase 'MbUnit v3.0.6.763/MBUnitProblem/DerivedFixture/test1' failed: 
   Expected values to be equal.
   
   Expected Value : 1
   Actual Value   : 2
   
   C:\Documents and Settings\test\My Documents\MahaLong\MBUnitProblem\MBUnitProblem\Class1.cs(45,0): at MBUnitProblem.DerivedFixture.SetUp()

TestCase 'MbUnit v3.0.6.763/MBUnitProblem/DerivedFixture/test2' failed: 
   Expected values to be equal.
   
   Expected Value : 1
   Actual Value   : 2
   
   C:\Documents and Settings\test\My Documents\MahaLong\MBUnitProblem\MBUnitProblem\Class1.cs(45,0): at MBUnitProblem.DerivedFixture.SetUp()

Disposing the test runner.


But if you remove all the typemock reference then there is no such problem.

I am using MBUnit, not sure whether the same problem occurs in other framework, though. I am using TestDriven.net
________
Big dick video
asked by (59.1k points)

1 Answer

0 votes
Hi,

This is a new bug, thanks for letting us know. The bug happens when a test class inherits from a base decorated with ClearMocks attribute.

As a workaround, ClearMocks attribute can be moved from the base class to the inheritor.

We'll let you know when this bug is fixed.

Regards,
Elisha
Typemock Support Team
answered by (12k points)
...