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.

Multiple Moq It.Is<string>() Matching Arguments

With Moq, is it valid to have more than one Matching Argument? It.Is<string>() In this example …

c# unit-testing mocking moq
Mocking Static Methods

Recently, I've begun to use Moq to unit test. I use Moq to mock out classes that I don't need …

c# unit-testing mocking moq
Mocking boto3 S3 client method Python

I'm trying to mock a singluar method from the boto3 s3 client object to throw an exception. But I need …

python mocking boto boto3 botocore
Mock an update method returning a void with Moq

In my test, I defined as data a List<IUser> with some record in. I'd like setup a …

c# .net mocking moq
PHPUnit Mock Objects and Static Methods

I am looking for the best way to go about testing the following static method (specifically using a Doctrine Model): …

php unit-testing mocking doctrine phpunit
How can I "sleep" a Dart program

I like to simulate an asynchronous web service call in my Dart application for testing. To simulate the randomness of …

unit-testing mocking dart
Mocking time in Java 8's java.time API

Joda Time has a nice DateTimeUtils.setCurrentMillisFixed() to mock time. It's very practical in tests. Is there an equivalent in …

java datetime mocking java-8 java-time
How to match null passed to parameter of Class<T> with Mockito

I have methods like these: public <T> method(String s, Class<T> t) {...} That I need …

java unit-testing mocking mockito
Javascript: Mocking Constructor using Sinon

I am pulling my hair out trying to figure out how to mock a constructor using sinon. I have a …

javascript unit-testing constructor mocking sinon
Mock attributes in Python mock?

I'm having a fairly difficult time using mock in Python: def method_under_test(): r = requests.post("http://localhost/post") …

python unit-testing testing mocking python-mock