In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to simulate the ...

learn more… | top users | synonyms

4
votes
1answer
50 views

Unit Testing and good use of matchers

I been having discussion with colleagues recently about good use of matchers. Consider the following sample: ...
5
votes
2answers
306 views

Mock/Stub out filesystem in F# for unit testing

I'm looking to do some basic verification testing on my functions that write to the filesystem. I took a hint from here on how to mock out the filesystem using an interface, but I'm kinda bummed on ...
7
votes
2answers
146 views

Building an IDE, block by — er, mock by mock

The opening sentence of an answer I received in my previous post snowballed, and led to completely ditching the previous approach. Mocking my IDE with a MockFactory ...
16
votes
2answers
4k views

Go on, mock my IDE

Because of the coupling with the VBIDE API (the extensibility library for the VBA IDE), unit testing the rubberduck refactorings, inspections and quick-fixes has been pretty much impossible, at least ...
1
vote
1answer
36 views

Testing class that transforms JSON into a spreadsheet

I am creating unit tests but the class uses objects that have long JSON. What can I do to improve the readability of this? In tests, only insert those JSON really needed for the test. The class I ...
1
vote
2answers
68 views

Unit Testing of parser method using py.test

This is my first time using py.test. All feedback for this test case is much appreciated. ...
3
votes
2answers
81 views

Using Mockito to verify that an object is saved

We've been reviewing some legacy code and have found differences in the preferred approach to how to write tests using Mockito. Both the following tests pass but which one is better and why? ...
2
votes
1answer
238 views

How to test “verification flow” code? would you test this at all?

I want to write unit-test to my code. However, while writing it, it seems all I can verify is that one method or the other were called once. My class is a manager that execute verification flow. It ...
3
votes
1answer
388 views

Unit testing HTTP requests

I would like to unit test my web requests, so on top of my head I came up with the solution below. Since it seems to be working fine, I'm posting it on this site. Though it doesn't feel very dynamic, ...
0
votes
0answers
91 views

Unit test for running a query, using Mockito

What's happening here is we are testing QueryRunner.RunQuery(ANBQuery q) The method calls methods of two other objects, ...
4
votes
3answers
2k views

Unit testing a servlet in a meaningful way

I have to write a unit test for the method processRequest in the servlet below and I'm wondering if: It just shouldn't be done. The class should be rewritten / ...
4
votes
1answer
387 views

Using a factory class for TextWriter than can be stubbed/mocked

This is my factory class: ...
2
votes
1answer
47 views

Mockable adapters

The inspiration for this question comes from a talk by IanCooper; in particular, this remark: Never mock somebody else's interface... you want to mock your abstraction of how you call the third ...
5
votes
1answer
171 views

Mock user table class

I've just created my first tests using mock classes. So far my tests are running much faster and now I guess I'm solely focusing on a single class (in this case I'm testing UserTable and mocking the ...
1
vote
1answer
37 views

Is building a test instance from a mix of both mock and real objects OK?

I am new to android testing and would like to try start off in the correct direction, so I am trying to understand if this is the correct way to test a particular method or if there is some best ...
1
vote
1answer
251 views

State and Interaction based testing using jMockIt

I am new to jMockIt and so wanted to learn it. I thought of implementing a synonym servlet kata. The servlet takes a word as input and returns the synoyms of the words as a comma seperated string. The ...
6
votes
1answer
1k views

Ugly code unit testing with PHPUnit and Doctrine2 (an ORM)

I am trying to unit test a small class that I consider part of the "business-logic" layer of my project. It mostly just interact's with Doctrine's entity manager and a couple of entities with a ...
4
votes
1answer
648 views

PHP wrapper around an API - best practices

Here's a PHP wrapper around a public OAuth2 REST API. I would love to hear your thoughts and comments. Testing was a bit frustrating since I tried for my first time. Not sure if I have done the ...
1
vote
2answers
337 views

Possible fake testing with Rhino mock

I'm new to Rhino mock and I would like to know if the test I did is not fake testing, as I've read a lot about it. Are there any improvements that need to be done? ...