
(in asp.net)
Does this work with WebAii somehow?
21 Answers, 1 is accepted
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.

So here's the scenario:
- I make an ASP.NET site, contains masterpages and a bunch of controls and webforms. The data for the site is powered by OpenAccess...
- 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...
- profit?
Steve

Thanks,
Bob
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.
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.
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.
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.

Also, this would be awesome...how does it integrate with OpenAccess?

Thanks for the information.
Bob
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.

What do you mean by "functional test" (I know what that means), but justmock doesn't test functionality?
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.

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?
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

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 :)
Thank you for the screenshots. However to solve the issue, you can try the following steps:
- 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.
- 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

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 (:

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
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 >>

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
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 >>