So, what is this?

22 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 12 Apr 2010 Link to this post

    Can I get a real world example on using this product?

    (in asp.net)

    Does this work with WebAii somehow?
  2. Chris
    Admin
    Chris avatar
    221 posts

    Posted 13 Apr 2010 Link to this post

    Hello Steve,
    JustMock is a mocking tool which you can use in your unit tests to isolate your unit tests from dependencies which you normally wouldn't like to test like web services, some third party libraries or components and so on.
    You could read more about JustMock here: http://www.telerik.com/products/mocking/features.aspx.
    You could also install the tool and just give it a try.
    The following blog post could help you get started:

    http://blogs.telerik.com/hristokosev/posts/10-04-06/mock_just_mock_justmock.aspx
    http://blogs.telerik.com/hristokosev/posts/10-04-12/justmock_beta_available_for_download.aspx
    http://weblogs.asp.net/mehfuzh/archive/2010/04/12/justmock-is-here.aspx

    Additionally the installation contains documentation and examples which you could also find useful.

    Greetings,
    Chris
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 20 Apr 2010 Link to this post

      I just got off the launch webinar and I'm still so totally confused by where I would use this :) Some of us come from smaller shops where we don't have Unit Testing, or use WebAii to store some quick tests...

    So here's the scenario:
    1. I make an ASP.NET site, contains masterpages and a bunch of controls and webforms.  The data for the site is powered by OpenAccess...
    2. Now JustMock comes in...what do I do with it (real world scenario), where does it plug in, basic beginners intro...without using any specific terminology...
    3. profit?
    Can we get a blog post perhaps?  Right now it seems like a ton of extra coding (perhaps less than other Mocking tools, but Ive never used others to know the difference) with little payoff.

    Steve
  5. Robert Clausen
    Robert Clausen avatar
    2 posts
    Member since:
    Aug 2007

    Posted 21 Apr 2010 Link to this post

    We are lost and it is not the show. We have not used another mocking tool. We would like to use unit testing and other testing tools to improve our code. We are producing asp.net web applications. We are using VB.NET language. We have installed Just Mock. Now what do we do. We have perused the examples, which show the different syntaxes in C#. We really do not know how to get started. Can you point us to some getting started examples, which shows us how to set everything up.

    Thanks,
    Bob
  6. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 22 Apr 2010 Link to this post

    Hello Robert,

    I will send you a getting started example for JustMock in VB  probably by end of today, i will also add that to the VB examples so that it will be available in the next build.

    Regards,
    Mehfuz
    the Telerik team


    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 22 Apr 2010 Link to this post

    Hi Robert ,

    As said in my last answer i am attaching a traditional example with JustMock using VB. Let me know if that is of any help to you.



    Regards,
    Mehfuz

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 22 Apr 2010 Link to this post

    Hi Steve,

    Here are some light on the scenario that could be of your help in deciding to use mocking tool or not

    I make an ASP.NET site, contains masterpages and a bunch of controls and webforms.  The data for the site is powered by OpenAccess...

    => As the complexity of your site grows , mocking frameworks helps you test your product from the logical point of view which means let's say you have an accounts service that  does a critical cacluation[logical layer] that is imporant for you business. Mocking framework helps you test this type cases separtely without considering IIS, database or other dependencies.

    Now JustMock comes in...what do I do with it (real world scenario), where does it plug in, basic beginners intro...without using any specific terminology...

     => I made post on how get started with a simple scenario, may be you can take a look at this :
    http://weblogs.asp.net/mehfuzh/archive/2010/04/13/doing-your-first-mock-with-justmock.aspx

    profit?

    => As , mocking framework enables you to test your product more deeply , it sure eliminates the chance of failure at production and thus helps reduce maintenance cost.    

    Hope these helps,
    Mehfuz



    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Chris
    Admin
    Chris avatar
    221 posts

    Posted 22 Apr 2010 Link to this post

    Hi Robert, Steve,
    You're absolutely right. We'll need more How-Tos and we'll need to explain better what's the benefit of using JustMock to people who've never used a mocking framework and even to people who haven't done much unit testing. Till now we've mostly described JustMock in a language which is familiar to people who have used some other mocking framework but we'll try to do better.

    Unit testing ASP.NET WebForms could be really painful but it really depends on how you've structured your application. Anyway most of the time you'll want to test only one part of it and isolate the current test from other dependencies so a mocking framework could really help you in this direction.
    Maybe you could help you get started: http://p2p.wrox.com/content/articles/testing-aspnet-webforms.

    If at some point you decide to go the MVC path where things are much better in terms of testability you could find this article helpful: http://msdn.microsoft.com/en-us/magazine/dd942838.aspx.

    Additionally if you're dealing with a lot of legacy code and you're not starting your application from scratch, I strongly recommend this book: http://www.amazon.com/dp/0131177052/?tag=sollc-intl-20.

    In the next couple of months we'll try to produce more videos and getting started documents and I hope they'll help you see how JustMock could improve your productivity and help you create better unit tests.

    Greetings,
    Chris
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 22 Apr 2010 Link to this post

    Would you be able to throw in an integration with WebAii\WebUI perhaps?  We do have a license for those as well, and will probably get the Ultimate Collection when it comes out so we'll have Mock as well...we just need to know if we need to (or can) use it in an ASP.NET environment.

    Also, this would be awesome...how does it integrate with OpenAccess?
  11. Robert Clausen
    Robert Clausen avatar
    2 posts
    Member since:
    Aug 2007

    Posted 22 Apr 2010 Link to this post

    Thanks for the reply. It is going to take some time to process the information you sent. It looks like we will need to make some changes to the way we code our applications to be able to get the best use out of Just Mock.
    Thanks for the information.
    Bob
     
  12. Chris
    Admin
    Chris avatar
    221 posts

    Posted 23 Apr 2010 Link to this post

    @Robert
    Should you have some other questions, please don't hesitate to contact us.

    @Steve
    We haven't planned any Integration with WebUI for now as WebUI is mostly used for functional tests while JustMock helps with the unit tests but we could think on some possible integration points.
    We'll definitely support ASP.NET and OpenAccess even with the first version of JustMock and we'll try to provide more examples in this direction with the next JustMock builds.

    Best wishes,
    Chris
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  13. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 23 Apr 2010 Link to this post

    Thanks for the info

    What do you mean by "functional test" (I know what that means), but justmock doesn't test functionality?
  14. Chris
    Admin
    Chris avatar
    221 posts

    Posted 26 Apr 2010 Link to this post

    Hello Steve,
    You could find good descriptions of Unit Tests and Functional Tests here:
    http://www.c2.com/cgi/wiki?UnitTest
    http://www.c2.com/cgi/wiki?FunctionalTest

    In short, Functional Tests usually test some requirements or acceptance criteria by interacting straight with the GUI of the application while Unit Tests test some particular piece of code (that's why they are often called "developer tests").

    Hope this information helps.

    All the best,
    Chris
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  15. cyguo
    cyguo avatar
    12 posts
    Member since:
    Aug 2004

    Posted 28 Sep 2010 Link to this post

    Dear Sir:
    It cannot work using transferfundsfixture.zip, but the test item "ShouldAssertFundTransfersBetweenTwoCurrencyAccounts" shows "Not Executed in Unit Test Window." Why is it? May I have another example in VB.Net and in Visual Studio 2008?
  16. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 28 Sep 2010 Link to this post

    Hi C.Y Guo,

    Thank you for sending the issue. I have attached another project that contains the transfer funds example using the latest JustMock SP1 release.

    Please let us know, if you are having further issues. Additionally, you can take a look at \%Program_Files%\Telerik\JustMock\Examples\Telerik.JustMock.VBExamples.sln for more examples that might be helpful in getting started with JustMock and Visual Basic.

    Kind Regards,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. cyguo
    cyguo avatar
    12 posts
    Member since:
    Aug 2004

    Posted 28 Sep 2010 Link to this post

    Dear Sir:
    I've tried examples in \%Program_Files%\Telerik\JustMock\Examples\Telerik.JustMock.VBExamples.sln. It works but how it works without importing Telerik.JustMock in program.

    Secondly, it's strange that test item is gone after pressing button Run selected tests. Please see the images attached. Thank you :)  

  18. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 30 Sep 2010 Link to this post

    Hi C.Y. GUO,

    Thank you for the screenshots. However to solve the issue, you can try the following steps:

    1. As you are using localized version of visual studio, this could well be an integration issue. In worse case, the JustCode test runner is not installed / working properly. Therefore, please try a new version of JustCode if you are using an old one or try re-installing.
    2. Alternatively, you can use TestDriven.Net or MSTest (that comes with Visual Studio) unit test runner which is also supported with JustMock.

    Hope this addresses your problem.

    Kind Regards,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. cyguo
    cyguo avatar
    12 posts
    Member since:
    Aug 2004

    Posted 30 Sep 2010 Link to this post

    Hi, 

    Finally, I knew what the problem is. It works if program is rebuilt in Unit Test Window of JustCode showing test items, but it works no matter program is rebuilt in Test Result Window. So that's the reason why my test items in Unit Test Window are gone.

    thank you (:
  20. Asad
    Asad avatar
    2 posts
    Member since:
    Dec 2011

    Posted 15 Dec 2011 Link to this post

    I looked at the Vb example you provided. I need an example of how i can ignore a Sub method Call. (Function returning void). Basically i have a entity which is calling a Sub which i would like to ignore. Eg :

    Class Foo()
    public Sub DoSomething()
    // Do something here
    End Sub
    End Class

    Class ToTest
     Public Sub methodTOTest()
     'Some implementation
    dim temp = new Foo()
    Foo.DoSomething
    End Sub
    End Class

    So i would like to know
    1. how can i replace the foo object with a fake object.
    2. how to ignore Subs from this Foo object.

    Thanks and Regards.
    Asad Palekar
  21. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 15 Dec 2011 Link to this post

    Hi Asad,
    Thanks again for sending the question. Please check following mock code:
    Dim foo = Mock.Create(Of Foo)
     
    Mock.Arrange(AddressOf foo.DoSomething).MustBeCalled()
                                                      
    foo.DoSomething()
     
    Mock.Assert(foo)

    Here I am not only ignoring the DoSomething call,  but also asserting that it is invoked as expected.

    Moreover, it is to note that you have to reference Telerik.JustMock.VisualBasic in order mock Subs since it is not supported to pass Sub in expression in VB 9.

    But for VB 10 you can directly reference Telerik.JustMock.dll as in VB 10 subs are fully supported in lambda expression. In short, for functions you can use the Function() keyword but for subs (void methods) you need to call it with address of keyword in .net 3.5


    Kind Regards,
    Mehfuz
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  22. Asad
    Asad avatar
    2 posts
    Member since:
    Dec 2011

    Posted 16 Dec 2011 Link to this post

    Hi Ricky,

    Thanks for the reply. But i am afraid it dint answer my first question fully.

    1. I wanted to call ToTest.MethodToTest() which will internally call foo.DoSomething. So how can i mock this instance without injecting the mocked foo object via arguments or constructor.

    2. I tried to use the addressof, but i see only 5 methods of the object where as i have some more. I have referenced Visualbasic dll in my project but while importing there is no namespace available for VisualBasic.

    I only get
    Imports Telerik.JustMock



    Thanks and Regards,
    Asad Palekar
  23. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 19 Dec 2011 Link to this post

    Hi Asad,
    Thanks again for the prompt reply, In order to mock a method from a type that is not injected via constructor or dependency injection, you can use the future mocking feature in JustMock. More information on this can be found at this post:

    http://weblogs.asp.net/mehfuzh/archive/2011/12/02/future-mocking-with-ignoreinstance.aspx

    Next, the reference for VB9 is Telerik.JustMock.VisualBasic.dll. However, the imports remains the same which is:

    Imports Telerik.JustMock

    Once you have the above reference, you should have the options that will enable you to pass up to 9 arguments for Sub using addressof. 


    Finally, here is one complete example that further shows future mocking in VB
    <TestMethod()>
    Public Sub ShouldAssertFutureMocking()
     
        Dim service = Mock.Create(Of LoginService)()
     
        Dim username = "JM"
        Dim password = "pass"
     
        Mock.Arrange(Function() service.ValidateUser(username, password)).Returns(True).IgnoreInstance()
     
        Assert.IsTrue(New LegacyCode().CheckUser(username, password))
     
    End Sub
     
    Public Class LegacyCode
        Public Function CheckUser(userName As String, password As String) As Boolean
            Return New LoginService().ValidateUser(userName, password)
        End Function
    End Class
     
    Public Class LoginService
        Public Function ValidateUser(userName As String, password As String) As Boolean
            Return False
        End Function
    End Class

    Hope this answers your question.

    Kind Regards,
    Mehfuz
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft R3 2016 release webinar banner