Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dependency Injection with a Mocking framework. #105

Open
JoanComasFdz opened this issue Mar 11, 2016 · 3 comments
Open

Support Dependency Injection with a Mocking framework. #105

JoanComasFdz opened this issue Mar 11, 2016 · 3 comments

Comments

@JoanComasFdz
Copy link

First of all thanks a lot for this work, its an amazing concept! I am trying the 30 days trial with a relatively small C# solution.

Unfortunately I cannot use the tool because it always says that it cannot create an instance of the type. On 90% of the classes. My guess is that whenever a constructor receives injected interfaces, Alive cannot create mocks for them.

It would be great if Moq or NSubstitute or any mocking framework was used, so classes with injected dependencies can be constructed and the mocks can be configured to see the data flow as you type new return values for methods and properties. Just like it works with any other base type.

@Ijwu
Copy link

Ijwu commented Mar 11, 2016

Supporting mocking constructor arguments generally would be a pretty fantastic feature.

@AmadeusW
Copy link
Member

It sounds like you already have mocks in place. If you have any unit tests that use mock and eventually lead to invocation of the method you're interested in, then you can should use these tests to start up Alive.

Take a look at "Leverage test cases" (second picture) in this guide to see how to start Alive with a test case. Please let us know if anything goes wrong, and we will make sure that your mocking and DI framework works fine.

Do you want Alive to automatically scan the solution for mocks and use them instead?

@Ijwu in long-term plans we want to empower developer with more control on how Alive starts on a method, which would allow you to set up mocks, fields etc without using a test case.

@JoanComasFdz
Copy link
Author

Hi Andrew, yes I read about running the tests in your documentation afterwards and I'll be testing that some time this week.

But still, the concept I was hoping for is to be able to change return values of an method parameter on real time to see how the data flow changes without having to rewrite a test or write a new one, so a class like this can actually be constructed without the need of a helper static method, but IFoo.Bar() return value can be changed on your parameters popup window.

public class MyClass
{
   public MyClass(IFoo foo)
   {
        this.foo = foo;
    }

    public int Do(int value)
    {
        return this.foo.Bar() + 1;
    }
}

This can really help understanding legacy code even faster than reading multiple unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants