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.

image

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)

Proxy mode

  1. Mock interfaces and classes with virtual methods
  2. Mock properties that includes indexers
  3. Set raise event for specific calls
  4. Use matchers to control mock arguments
  5. Assert specific occurrence of a mocked calls.
  6. Assert using matchers
  7. Do recursive mocks
  8. Do Sequential mocking ( same method with argument returns different values or perform different tasks)
  9. Do strict mocking (by default and i prefer loose , so that i can use it as stubs)

Elevated mode

  1. Mock static methods
  2. Mock final methods
  3. Mock sealed classes
  4. Mock Extension methods
  5. Partially mock a  class member directly using Mock.Arrange
  6. 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:

 

  1. var lvMock = Mock.Create<ILoveJustMock>();
  2.  
  3.  // set your goal
  4.  Mock.Arrange(() => lvMock.Response(Arg.Any<string>())).Returns((int result) => result);
  5.  
  6.  //perform
  7.  string ret =  lvMock.Echo("Yes");
  8.  
  9.  Assert.Equal(ret, "Yes");
  10.  // make sure everything is fine
  11.  Mock.Assert(() => lvMock.Echo("Yes"), Occurs.Once());

 

Hope that helps to get started,  will cover if not :-).

5 Comments

  • Hello.

    As the title says, what are the pro and cons for someone already using Rhino mock?

    Thanks.

  • @Marnheus
    1. Simpler clean syntax to use and learn.
    2. Ability to use anonymoulsy assert expecatations in Mock.Assert
    3. Features like sequential mocking.
    Are Few to add.
    More...
    Its gives final and static mehtod supports , even you can mock framework classes.

  • Looks nice, a lot of the same ideas that I have in FakeItEasy. I like the syntax.

  • Three questions:

    1. What will it cost?
    2. Does this price give an adequate value compared to the free (and very good) 'Moq'-Framework? (How and why...)
    3. How does it compare to its commercial (and very good) alternative Typemock Isolator?

    In sum: Do we need another mocking framework? And if so, why?

    - Thomas

  • Hi Thomas,

    The pricing is yet to be decided but you could read the last comment in the following blog post: http://blogs.telerik.com/hristokosev/posts/10-04-06/mock_just_mock_justmock.aspx

    Regarding to moq , i have made a comment on the next post please check that as well.
    http://weblogs.asp.net/mehfuzh/archive/2010/04/13/doing-your-first-mock-with-justmock.aspx#7443407


    Regards,
    M

Comments have been disabled for this content.