Are there any automocking libraries in the Java world?
I'm looking for something similar to the structuremap or eleution automocking containers in the .NET world ...
I'm looking for something similar to the structuremap or eleution automocking containers in the .NET world ...
I want to start using mock objects on my c# project. After a quick google I've found that most folks use one of the below: NMock EasyMock.Net TypeMock Isolator Rhino Mocks Moq Does Microsoft provide a similar framework for mocking? I'm using Visual Studio tests for my unit test now. ...
In the following code why does mockTest.ToString() return Null? EDIT: Added comment into example code to show how to fix the problem. Public Sub Main() Try Dim test = New TestClass If test.ToString <> "stackoverflow rules" Then Throw New Exception("Real Failed: Actual value: <" + test.ToString + ">") ...
I must be missing something. I'm trying to stub methods on a class in PHPUnit, but when I invoke the method on the mock object, it tells me that method is undefined. Example class to stub: namespace MyApp; class MyStubClass { public function mrMethod() { // doing stuff } } To stub it, I write: // specifying all ge...
I have django code that interacts with request objects or user objects. For instance something like: foo_model_instance = models.get_or_create_foo_from_user(request.user) If you were going to test with the django python shell or in a unittest, what would you pass in there? Here simply a User object will do, but the need for a mock req...
Hello, So in my domain I have 3 objects. User, Item and Tag. Each user has items and tags, each item has tags and each tag has items. The objects look a little like this: public class User { public List<Item> Items { get; set; } public List<Tag> Tags { get; set; } } public class Item { public List<Tag> Tags { get; set; } ...
Using RhinoMocks - can I fetch the parameters of a called function? I mean; can I get some of the unknown parameters from the function call out? I have a mock, and I expect some function to be called on this. I know one of the parameters, but the other one is unknown as this comes from the class that uses the mock and calls a function ...
Hello, I have a .NET application with a web front-end, WCF windows service back-end. The application is fairly simple - it takes some user input, sending it to the service. The service does this - takes the input (excel spreadsheet), extracts the data items, checks SQL db to make sure the items are not already existing - if they do not ...
If you have a method that needs to be tested that takes a list of SearchResults public virtual void ProcessResults(IList<SearchResult> list) { //Code to tests here } How do you mock up that list of SearchResult? Note: No low-level injection frameworks (eg TypeMock) allowed. ...
We've been trying write unit tests for a worker class written in C#, which mocks out a third party API (COM based) using moq to dynamically create the mock objects. NUnit is our unit testing framework. This third party component implements a couple of interfaces, but also needs to call back into our worker class using events. Our plan w...
Hi, I am trying to get to grips with mocking and ReSharper by watching this demo http://www.bestechvideos.com/2008/06/08/dimecasts-net-introduction-to-mocking-with-moq I'm sure I followed the code correctly but I'm getting errors. Could you give me some pointers as to were I'm going wrong? errors:-class name is not valid at this point e...
I am trying the following, but I am getting : Object reference not set to an instance of an object. HttpContextBase mockContext = MockRepository.GenerateMock<HttpContextBase>(); mockContext.Expect(c => c.Server.HtmlEncode("")).IgnoreArguments().Return(""); mockContext.Expect(c => c.Server.HtmlDecode("")).Return(""); controller.Con...
Using RhinoMocks - how can I say "whenever some function is called from now on - it should return some value". I'd like to say something like this: fakeCalculator.WhenCalled(factory => factory.AddNumbers(1, 2)).Return(3); And then - when the AddNumbers function is called with 1 and 2 - it will return 3. I.e. I want to define this ...
I like to know what mock objects are in Java. Why do we create them and what are their uses? ...
Hi, We are writing a client for a remote service that exposes SOAP web services and publishes a WSDL definition for those services. We don't have access to the system during testing, so we'd like to write a mock service. We're using Python for the client, so ideally we'd want to use Python for the mock server, although I suppose it's ...
Hi all, I have a method that I want to test which hits the database. From what I have read this is a perfect oppurtunity to use a mock. However the problem that I am facing is that I pass the object a string and then it creates an object and hits the db with this object i.e. public void test(string t) { Test t1 = new Test(t); d...
We are trying to use Fitnesse for our Functional test. Should i be mocking dependencies or should it be testing against the database? What are the Pros/Cons of either of the approach? The whole issue of testing against the DB is setting up data which is huge dependency. If we mock then is it real functional test? Thanks ...
Protocol buffer classes are marked final, presumably for efficiency; however, this makes them quite difficult to test with -- Mockito can't mock/spy on final classes. I've tried using PowerMockito with no success: I get a ClassFormatError when preparing the final class for the test. My solution up until now is to create mockable adapter...
I am trying to test the following code public void CleanUp() { List<ITask> tasks = _cleanupTaskFactory.GetTasks(); //Make sure each task has the task.Execute() method called on them } In my test I create a mocked implementation of _cleanupTaskFactory, and I want to stub the GetTasks() method to return a ty...
So a coworker and I are in a fairly heated debate. We are beginning a new project and we are attempting to use BDD. We are both first-timers and don't fully understand what practices should be used. We've written some specs and we are now implementing the code. Things are getting pretty tricky since there is a lot of database interaction...