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 Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
When I change code in a method covered by a test and rebuild, autorunner does not re-run the tests for that method. Isn't it supposed to? I guess it's called "SmartRunner" now, but it is enabled in Extensions and I can run the tests manually. It just doesn't run automatically. What am I missing?

Thanks
asked by DavidMann (720 points)

7 Answers

0 votes
Hi David,

The Smart-Runner should act as you described.
I couldn't recreate this behavior so it might be that it fails under certain conditions.

Does it always fail to act as expected (in every solution, in all the functions in a solution)?
Which version of Isolator do you use?
Which VS do you use?

Can you provide some other details that can help us reproducing it?
answered by alex (17k points)
0 votes
I've tried a couple of projects/Solutions - even a brand new, essentially empty one. I am running TypeMock 7.1.5.0 (upgraded from 7.0.4.0) with VS 2010 SP1 (10.0.40219.1). Here is my very basic test:


public class ClassUnderTest
{

public bool Foo()
{
return true;

}
}

[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
ClassUnderTest cut = new ClassUnderTest();
Assert.IsTrue(cut.Foo());
}
}

If I click TypeMock | RunAllTests from the VS menu, the test runs and passes as expected.
If I then change the Foo method to return false and recompile, the tests don't re-run and the Dashboard still shows green and the TypeMock Output window is blank.

If it helps, the sample project is attached as a ZIP file

Thanks.

ClassLibrary1.zip (Zipped sample project)
answered by DavidMann (720 points)
0 votes
Hi David,

It's a little hard to tell whether the runner acts as expected when using just one test.
I propose to examine the next scenario which should give you a better indication of the smart runner's behavior:


1. Open a new project and copy this code:
    public class ClassUnderTest
    {
        public bool Foo()
        {
            return true;
        }

        public int Goo()
        {
            return 1;
        }
    }

   [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            ClassUnderTest cut = new ClassUnderTest();
            Assert.IsTrue(cut.Foo());
        }

        [TestMethod]
        public void TestMethod2()
        {
            ClassUnderTest cut = new ClassUnderTest();
            Assert.AreEqual(1, cut.Goo());
        }
    }



2. Run the tests using Smart Runner
3. Change the returned value of Foo to false.
4. Build the solution

The expected behavior is:
When you first run the tests, both tests should run.
After chancing Foo and rebuilding, only TestMethod1 should run because it's affected by the code you changed.

You can check which of the tests ran by opening the output window and changing the form to Typemock.

Please let us know if it helps.
answered by NofarC (4k points)
0 votes
That works sometimes, but not all the time. In my real project, SmartRunner never runs.

Curioser and curiouser...
answered by DavidMann (720 points)
0 votes
Hi,

Thank you for the prompt reply.

I have some questions:

1) Does the runner act fine until some point and then it starts to run all test regardless to the code you change. Or, does it happen randomly?

2) Do you some times turn your machine off close VS or is it always opened?

3) If your haven't restarted your machine in a long time, can you restart it and check how the runner acts after you do?
answered by alex (17k points)
0 votes
I had deactivated SmartRunner because it wasn't working. I've since re-enabled it and restarted my whole machine. When I go back into VS and run my tests they don't work. I don't even get to the point of trying SmartRunner any more - 10 of 13 tests fail when I select TypeMock | Run All Tests from the menu. However, if I run them using a different test runner (DXCore Test Runner) all test pass. This is with NO changes to the tests themselves or the code under test.

Here is one method I'm testing (its about as basic as can be):
public bool ShouldShowAdminPanel(SPWeb web)
{
    return web.AssociatedOwnerGroup.ContainsCurrentUser;
}


This is in a class called "JobRunner". Here are two tests to exercise that method:
[TestMethod, Isolated()]
        public void ShouldShowAdminPanel_UserIsAdmin_ReturnTrue()
        {
            JobRunner runner = new JobRunner();
            var fakeWeb = Isolate.Fake.Instance<SPWeb>();
            Isolate.WhenCalled(() => fakeWeb.AssociatedOwnerGroup.ContainsCurrentUser).WillReturn(true);
            Assert.IsNotNull(runner);
            Assert.IsTrue(runner.ShouldShowAdminPanel(fakeWeb));
        }

        [TestMethod, Isolated()]
        public void ShouldShowAdminPanel_UserIsNotAdmin_ReturnFalse()
        {
            JobRunner runner = new JobRunner();
            var fakeWeb = Isolate.Fake.Instance<SPWeb>();
            Isolate.WhenCalled(() => fakeWeb.AssociatedOwnerGroup.ContainsCurrentUser).WillReturn(false);
            Assert.IsNotNull(runner);
            Assert.IsFalse(runner.ShouldShowAdminPanel(fakeWeb));
        }


If I change a test that did pass and recompile, SmartRunner does not re-run it.

Things are getting worse. Any ideas?

Thanks.
answered by DavidMann (720 points)
0 votes
Hi David,

We've made some work on the smart-runner. The version with these enhancements will be available soon but you can download a patch and see if it helps.

However, if the issue you are experiencing isn't solved by this patch, please send the error message that you get when a test fails along with the test.

Looking forward to your feedback.
answered by alex (17k points)
...