Open Source / Free alternative of Typemock Isolator
Asked Answered
P

5

18

Is there any F/OSS alternative of Typemock Isolator .NET?

Pavement answered 5/4, 2011 at 17:44 Comment(4)
So did you end up using Moles? If so, how was it?Delp
Nope, actually we ended up buying Typemock :)Pavement
I've been doing some research into Typemock for work, and am wishing I had it for a side project I'm working on. ... now that I've seen the light.Delp
Does this answer your question? Is there any open source mocking framework resembling TypeMock?Knox
M
20

Disclaimer: I work at Typemock

Typemock Isolator utilizes the CLR Profiler API to perform IL rewriting, thus allowing you to fake (mock) static methods and concrete classes. As far as I know, Moles does similar things to Isolator in terms of using the Profiler to mock those things, and it's free (but not open source).

All other open source frameworks using the Dynamic Proxy to implement interfaces and abstract classes in runtime, therefore they cannot mock sealed/static classes.

Mesoblast answered 6/4, 2011 at 8:51 Comment(3)
Thanks for the clarification, to be honest I like TypeMock it's just quite expensive, that's I'm looking for another similar toolPavement
I agree i love the way Typemock's API works and looks but its painfully expensive when selling it in vs other unit testing frameworksTrahern
+1 for too expensive, especially for a small startupBurny
C
11

I'm not familiar with all of the features of Typemock Isolator, but Moles is a free product that I've used for unit testing.

Carcass answered 5/4, 2011 at 18:25 Comment(2)
At the time this answer was given (April 2011), Moles was a free download. It has now been rebranded Fakes and put into Ultimate edition only.Carcass
Microsoft Fakes is available in the Ultimate and Premium SKUs of Visual Studio.Fiacre
J
6

I have used Typemock in my last project and am very happy with it. I went through the same pain of getting approval to purchase Typemock in my organization because of its cost. But in the end we were happy with our purchase.

I recently came across JustMock which is developed by Telerik. It can mock almost anything like Typemock and is also cheaper than Typemock, which is good. The better part is, they have a trimmed version of their product - JustMock Lite which is free. You can get started with the free version and then upgrade to the paid version if you need the advanced features like mocking sealed classes, non-virtual methods etc. That way you do not have to change your code when you upgrade to support advanced mocking scenarios.

Also JustMock uses Dynamic Proxy approach for simple mocking scenario's like interfaces, virtual methods and uses .NET profiling API only for the advanced features making the unit tests run faster for the simplest scenarios.

Jurassic answered 5/6, 2012 at 17:21 Comment(0)
F
3

I have created one - AutoFake. So you can replace whatever you want without a need to pay some money and with an opportunity to have a fast support from the opensource community. Here is a short example of what you can do:

public class Calendar
{
    public static DateTime Yesterday => DateTime.Now.AddDays(-1);
}

[Fact]
public void Yesterday_SomeDay_ThePrevDay()
{
    var fake = new Fake<Calendar>();

    var sut = fake.Rewrite(() => Calendar.Yesterday);
    sut.Replace(() => DateTime.Now).Return(new DateTime(2016, 8, day: 8));

    Assert.Equal(new DateTime(2016, 8, 7), sut.Execute());
}
Fulviah answered 30/5, 2020 at 1:5 Comment(2)
Great work on that. I'm using this on a few projects already.Botticelli
Happy to hear that. Feel free to ask whatever you want in our chat or GH. There is still much work there because it works on low byte-code IL level so that we have to cover tons of cases. But I've been working on this for 5 years (not fulltime ofc) and still have fun that's why the lib will be better and better.Fulviah
O
-1

I use Moq mocking library in my tests for mocking purposes. It's completely F/OSS (BSD license).

Opprobrium answered 6/4, 2011 at 8:13 Comment(3)
+1 Why was this downvoted? The Url was changed (I've submitted a change to fix it), but it's a perfectly legit answer to the question, IMHO.Dominican
I did not downvote, but perhaps it was because Moq lacks the ability to mock anything without a single change to target code (no need to add interfaces, etc.) - an ability which sets TypeMock apart. So in that way, it is not truly an alternative if you have legacy code and want to add test without making changes first. That said, the OP didn't give that level of detail so the downvote was probably unwarranted.Tedious
I don't consider this a true alternative simply because Moq does not provide mocking for sealed and static methods/classes.Accentuation

© 2022 - 2024 — McMap. All rights reserved.