Category "mocking"

How can I configure Moq to return new instance per call?

I am trying to write a simple test with moq. When calling the mocked method for the second time, after changing the return value from the first call, the moq fr

How to set up a stub and assigning a webresponse with Rhino mocking

I'm completely new to Rhino Mocks and mocking in general. I'm still wrapping my head around how to code the mocks. I have a test class which contains something

How to mock a local variables using mockito/powermock

I have a function as follows : private Response getHttpResponse(String url) { WebTarget target = client.target(url); Invocation.Builder requestBuilder =

Mockito ClassCastException - A mock cannot be cast

I have a method in the class AppleProcessor which I would like to test: public void process(Fruit fruit) { if(fruit.getType() == Fruit.APPLE) { fru

@patch decorator cannot set Provider

I tried patching a provider class by decorating a test method with @patch: class TestMyUnit(unittest.TestCase): ... @patch(provider.Provider,autospec=True) def

FastAPI: app.dependency_overrides affects other test files

I'm working with FastAPI. I've introduced in my test suite (pytest) app.dependency_overrides to test my app dependencies. Strangely enough, when I use it in a t

Best approach to mock hiredis library in C

I am writing a project that takes advantage of the hiredis redis client library. What is the best approach to mock this library for use in writing tests? For

How to mock Repository/Unit Of Work

In my app I have generic repository connected to controller through UnitOfWork. I want to unit test my app. To make this I need to mock db connection. Can you t

How can I mock nest typeorm database module in end to end (e2e) tests?

all. Include details about your goal: I'm trying to mock repository in e2e test Describe expected and actual results: Request to server will not have access

How to monkeypatch python's datetime.datetime.now with py.test?

I need to test functions which uses datetime.datetime.now(). What is the easiest way to do this?

How to mock location without enabling setting

I am looking for a way to be able to mock location without needing to use ACCESS_MOCK_LOCATION. I know that I need to have root, move app to the system. But whe

How to create tests w/Doctrine entities without persisting them (how to set id)

I'm working on tests for a Symfony2 project, and right now I'm looking for a way to create tests involving entity objects without persisting them. The problem i

Mock functions in Go

I'm puzzled with dependencies. I want to be able to replace some function calls with mock ones. Here's a snippet of my code: func get_page(url string) string {

Using WireMock with SOAP Web Services in Java

I am totally new to WireMock. Until now, I have been using mock responses using SOAPUI. My use case is simple: Just firing SOAP XML requests to different endp

How to mock browser requests based on har files?

I've exported a har file of my application. Now I would like to reuse it when the server is crashed (it's quite often issue). I was looking for an application t