mocking

Do we really need isolation frameworks to create stubs?

I have read this: http://martinfowler.com/articles/mocksArentStubs.html My concepts about a stub and a mock are clear. I understand the need of isolation frameworks like moq, rhinomocks and like to create a mock object. As mocks, participate in actual verfication of expectations. But why do we need these frameworks to create stubs. I wou...

A consistent and simple group of IDE and tools for embedded code and unit test in C++ ?

I’m starting a new firmware project in C++ for Texas Instrument C283xx and C6xxx targets. The unit tests will not run on the target, but will be compiled with gcc/gcov on a PC with windows (and run as well on PC) with simple metrics for tested code coverage. The whole project will be part of Cruise Control.NET for continuous integration...

Is there a way to undo Mocha stubbing of any_instance in Test::Unit

Much like this question, I too am using Ryan Bates's nifty_scaffold. It has the desirable aspect of using Mocha's any_instance method to force an "invalid" state in model objects buried behind the controller. Unlike the question I linked to, I'm not using RSpec, but Test::Unit. That means that the two RSpec-centric solutions there won't...

Soapui mocking services which return json

Microsoft Ajax can expose webservices which respond with json or xml depending on configuration. I would like to mock these services using soap ui. Using the wsdl I can do this to mock the services in the case where xml is returned, however how can I mock the response when JSON is returned? ...

What mock object framework should I use when developing in Python on the Google App Engine?

I am developing an application on the Google App Engine using Python (and Django, if that matters). Which mock object framework should I help to assist with unit tests? I see there are a number of standalone projects (i.e. http://python-mock.sourceforge.net), but I'm not sure if there's something built-in that I can use. Any ideas? ...

Moq basic questions

I made the following test for my class: var mock = new Mock<IRandomNumberGenerator>(); mock.Setup(framework => framework.Generate(0, 50)) .Returns(7.0); var rnac = new RandomNumberAverageCounter(mock.Object, 1, 100); rnac.Run(); double result = rnac.GetAverage(); Assert.AreEqual(result, 7.0, 0.1); The problem here was that I chan...

How to get started with testing(jMock)

Hello, I'm trying to learn how to write tests. I'm also learning Java, I was told I should learn/use/practice jMock, I've found some articles online that help to certain extend like : http://www.theserverside.com/news/1365050/Using-JMock-in-Test-Driven-Development http://jeantessier.com/SoftwareEngineering/Mocking.html#jMock And most ...

Boost.Test: Looking for a working non-Trivial Test Suite Example / Tutorial

The Boost.Test documentation and examples don't really seem to contain any non-trivial examples and so far the two tutorials I've found here and here while helpful are both fairly basic. I would like to have a master test suite for the entire project, while maintaining per module suites of unit tests and fixtures that can be run indepen...

Using jmock how to reuse parameter

I'm building a test, in wich i need to send question, and wait for the answer. Message passing is not the problem. In fact to figure out wich answer correspond to wich question, i use an id. My id is generated using an UUID. an i want to retrieve this id, wich is given as a parameter to a mocked object. It look like this: oneOf(messag...

Rails Fixtures vs. Mocks

Hi there, I'm developing a Rails app, and I was just talking with my colleague that we have a mix of fixtures and mocks in our tests, which we're doing using cucumber and Rspec. The question would be: when should each one be used? ...

How should I pass an object wrapping an API to a class using that API?

Hello everyone :) This is a revised/better written version of the question I asked earlier today -- that question is deleted now. I have a project where I'm getting started with Google Mock. I have created a class, and that class calls functions whithin the Windows API. I've also created a wrapper class with virtual functions wrapping ...

mocking command object in grails controller results in hasErrors() return false no matter what! Please help.

I have a controller that uses a command object in a controller action. When mocking this command object in a grails' controller unit test, the hasErrors() method always returns false, even when I am purposefully violating its constraints. The more baffling thing is that in production, hasErrors() works! So this is just a testing problem....

Mockito verify no more interactions but omit getters

Mockito api provides method: Mockito.verifyNoMoreInteractions(someMock); but is it possible in Mockito to declare that I don't want more interactions with a given mock with the exceptions of interactions with its getter methods? The simple scenario is the one in which I test that sut changes only certain properties of a given mock a...

ASP.NET MVC Unit Testing Controllers - Repositories

This is more of an opinion seeking question, so there may not be a "right" answer, but I would welcome arguments as to why your answer is the "right" one. Given an MVC application that is using Entity Framework for the persistence engine, a repository layer, a service layer that basically defers to the repository, and a delete method on...

mockito ArrayList<String> problem...

I have a method that I am trying to unit test. This method takes a parameter as an ArrayList and does things with it. The mock I am trying to define is: ArrayList<String> mocked = mock(ArrayList.class); which gives a [unchecked] unchecked conversion" warning. ArrayList<String> mocked = mock(ArrayList<String>.class); gives me an...

Intelligent serial port mocks with Moq

I have to write a lot of code that deals with serial ports. Usually there will be a device connected at the other end of the wire and I usually create my own mocks to simulate their behavior. I'm starting to look at Moq to help with my unit tests. It's pretty simple to use it when you need just a stub, but I want to know if it is possib...

Advice on Mocking System Calls

I have a class which calls getaddrinfo for DNS look ups. During testing I want to simulate various error conditions involving this system call. What's the recommended method for mocking system calls like this? I'm using Boost.Test for my unit testing. ...

In Ruby, using Cucumber, should I mock out calls to a webservice?

All, I'm using Cucumber for acceptance testing a Ruby command line utility. This utility pulls data in from a webservice. I understand Cucumber is for acceptance testing and tests the whole stack but I still need to provide consistant replies from the webservice. Should I mock the webservice? If yes, how? What's the best approach here...

Mocking with java 1.4

Is there any framework, whick allows to mock concrete classes, not only interfaces in java 1.4? I have third party code with a singleton class, where I wanna change one function, without touching orignal code. Is it possible? ...

Telerik JustMock a Property Read

I am trying to mock a Property using Telerik JustMock. public WorkitemBusinessObject mock() { var mockContext = Mock.Create<BusinessObjectContext<Workitem>>(); var workitemList = new List<Workitem> { new Workitem {Title="First Workitem"} }; Mock..Arrange(() => mockContext.Table)...