JustMock is here !!
As announced earlier by Hristo Kosev at Telerik blogs , we have started giving out JustMock builds from today. This is the first of early builds before the official Q2 release and we are pretty excited to get your feedbacks.
Its pretty early to say anything on it. It actually depends on your feedback. To add few, with JustMock we tried to build a mocking tool with simple and intuitive syntax as possible excluding more and more noises and avoiding any smell that can be made to your code [We are still trying everyday] and we want to make the tool even better with your help. JustMock can be used to mock virtually anything. Moreover, we left an option open that it can be used to reduce / elevate the features just though a single click. We tried to make a strong API and make stuffs fluent and guided as possible so that you never have the chance to get de-railed. Our syntax is AAA (Arrange – Act – Assert) , we decided to stay away from Record – Reply model where you record your mock first , then reply and verify them. This is quite unnatural (like gotos in c/c++) and does not conform to the right flow. Thus, AAA syntax is the right one to choose. Also, having two different syntaxes is even more confusing so we decided to keep with one and only one.
Currently, here are the things you can do with JustMock ( will cover more in-depth in coming days)
- Mock interfaces and classes with virtual methods
- Mock properties that includes indexers
- Set raise event for specific calls
- Use matchers to control mock arguments
- Assert specific occurrence of a mocked calls.
- Assert using matchers
- Do recursive mocks
- Do Sequential mocking ( same method with argument returns different values or perform different tasks)
- Do strict mocking (by default and i prefer loose , so that i can use it as stubs)
- Mock static methods
- Mock final methods
- Mock sealed classes
- Mock Extension methods
- Partially mock a class member directly using Mock.Arrange
- Mock MsCorlib (we will support more and more members in coming days) , currently we support FileInfo, File and DateTime.
These are few, you need to take a look at the test project that is provided with the build to find more [Along with the document]. Also, one of the features that I will be using it for my next OS projects is the ability to run it separately in proxied mode which makes it easy to redistribute and do some personal development in a more DI model and my option to elevate as i go.
I’ve surely forgotten tons of other features to mention that i will cover time but don’t for get the URL : www.telerik.com/justmock
Finally a little mock code:
- var lvMock = Mock.Create<ILoveJustMock>();
- // set your goal
- Mock.Arrange(() => lvMock.Response(Arg.Any<string>())).Returns((int result) => result);
- string ret = lvMock.Echo("Yes");
- Assert.Equal(ret, "Yes");
- // make sure everything is fine
- Mock.Assert(() => lvMock.Echo("Yes"), Occurs.Once());
Hope that helps to get started, will cover if not :-).