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 which some of the smarter mocking tools are planning to remove from their coming release or even don’t have [its always fun to lean from each other] and honestly its kind of hard to comprehend . Overall more signals equals more complexity , reminds me of 37 signals :-).
Currently, here are the things you can do with JustMock ( will cover more in-depth in coming days)
- Mock interfaces and class with virtuals
- 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 calls
- Mock final class
- 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 :-).