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.

Mock a constructor with parameter

I have a class as below: public class A { public A(String test) { bla bla bla } public String check() { bla …

java junit mocking mockito powermock
Using Mockito with multiple calls to the same method with the same arguments

Is there a way to have a stubbed method return different objects on subsequent invocations? I'd like to do this …

java mocking mockito
How to mock location on device?

How can I mock my location on a physical device (Nexus One)? I know you can do this with the …

android gps location mocking
What is Mocking?

What is Mocking?                                                                                                    .

unit-testing mocking
Can Mockito stub a method without regard to the argument?

I'm trying to test some legacy code, using Mockito. I want to stub a FooDao that is used in production …

java unit-testing mocking mockito
How can I mock an ES6 module import using Jest?

I want to test that one of my ES6 modules calls another ES6 module in a particular way. With Jasmine …

javascript node.js mocking ecmascript-6 jestjs
How can I mock requests and the response?

I am trying to use Pythons mock package to mock Pythons requests module. What are the basic calls to get …

python mocking request
What's the best mock framework for Java?

What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework?

java unit-testing mocking
How to tell a Mockito mock object to return something different the next time it is called?

So, I'm creating a mock object as a static variable on the class level like so... In one test, I …

java unit-testing junit mocking mockito
What's the difference between faking, mocking, and stubbing?

I know how I use these terms, but I'm wondering if there are accepted definitions for faking, mocking, and stubbing …

unit-testing mocking language-agnostic terminology definition