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

Notification

Icon
Error

Impact detection does not detect added constructor required by Moq
ljohnston
#1 Posted : Tuesday, May 16, 2017 7:48:31 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/17/2014(UTC)
Posts: 17

Thanks: 5 times
Was thanked: 3 time(s) in 3 post(s)
Here's another impact detection issue I came across.

The way Moq creates mocks may make it difficult/impossible to detect this case but I wanted to make sure you were aware of it regardless.

Create a project with Machine.Specifications, Machine.Specifications.Should, and Moq Nuget packages. Enable NCrunch with run impacted tests automatically.

Add the following test:

Code:
     
    public class test {
       
        It should_create_mock = () => {
            Mock.Of<Foo>().ShouldNotBeNull();
        };
        
    }

    public class Foo {

        //protected Foo() {
        //}


        public Foo(String value) {
        }
    }


NCrunch will correctly detect that the test fails because Moq cannot create an instance of the class because it does not have a no argument constructor (Castle.DynamicProxy.InvalidProxyConstructorArgumentsException).

Now uncomment the no argument constructor in Foo. Impact detection will not detect that the code under test has changed and that the test will now succeed (manually running the test will correctly detect that it now passes).

After the latest fixes I'm really happy overall with the way impact detection works and get a lot of value out of it. Thanks for all your hard work.
Remco
#2 Posted : Tuesday, May 16, 2017 10:19:09 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 606 times
Was thanked: 697 time(s) in 667 post(s)
Hi, thanks for sharing this problem.

This is definitely a hard one. The critical dependency here sits on the result of a reflection call inside an uninstrumented library, so without instrumenting Moq or hacking the CLR, I'm not sure yet of a way to handle such a complex case. I'll have a think about it some more. Reflection is an area that isn't really handled by the engine yet, though I do have a few ideas that I'm working on.

I'm glad the impact detection system is working well for you now. If you find any more of these, please let me know so that they can be assessed and hopefully addressed.
1 user thanked Remco for this useful post.
ljohnston on 5/16/2017(UTC)
Users browsing this topic
Guest (3)
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.020 seconds.