Top "Mocking" questions

Mocking and faking are ways to isolate code or components to ensure that unit tests run against the testable unit of code only without actually utilizing other components or dependencies of an application.

Mockito - @Spy vs @Mock

Mockito - I understand a spy calls the real methods on an object, while a mock calls methods on the …

java unit-testing mocking mockito spy
How do you mock out the file system in C# for unit testing?

Are there any libraries or methods to mock out the file system in C# to write unit tests? In my …

c# unit-testing mocking
Android Fake GPS location apps do not work anymore

I used to work with this application: https://play.google.com/store/apps/details?id=com.fakegps.mock&hl=…

android google-maps gps mocking location-services
Using Mockito to mock a local variable of a method

I have a class A that needs to the tested. The following is the definition of A: public class A { …

java mocking mockito functional-testing
mockito callbacks and getting argument values

I'm not having any luck getting Mockito to capture function argument values! I am mocking a search engine index and …

java unit-testing mocking mockito
How to unit test a Node.js module that requires other modules and how to mock the global require function?

This is a trivial example that illustrates the crux of my problem: var innerLib = require('./path/to/innerLib'); function …

javascript node.js mocking
How can I get PHPUnit MockObjects to return different values based on a parameter?

I've got a PHPUnit mock object that returns 'return value' no matter what its arguments: // From inside a test... $mock = $…

php unit-testing mocking phpunit
How to mock localStorage in JavaScript unit tests?

Are there any libraries out there to mock localStorage? I've been using Sinon.JS for most of my other javascript …

javascript unit-testing mocking local-storage sinon
Mock private method with PHPUnit

I have a question about using PHPUnit to mock a private method inside a class. Let me introduce with an …

php mocking phpunit
Using mock patch to mock an instance method

I'm trying to mock something while testing a Django app using the imaginatively named Mock testing library. I can't seem …

python mocking