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.

Verify object attribute value with mockito

I have a method call which I want to mock with mockito. To start with I have created and injected …

java mocking mockito
throw checked Exceptions from mocks with Mockito

I'm trying to have one of my mocked objects throw a checked Exception when a particular method is called. I'm …

java mocking mockito
Using Mockito to test abstract classes

I'd like to test an abstract class. Sure, I can manually write a mock that inherits from the class. Can …

java unit-testing mocking abstract-class mockito
Using python's mock patch.object to change the return value of a method called within another method

Is it possible to mock a return value of a function called within another function I am trying to test? …

python unit-testing mocking patch
How do I mock a service that returns promise in AngularJS Jasmine unit test?

I have myService that uses myOtherService, which makes a remote call, returning promise: angular.module('app.myService', ['app.myOtherService']) .factory(…

javascript angularjs unit-testing mocking jasmine
Mock HttpContext.Current in Test Init Method

I'm trying to add unit testing to an ASP.NET MVC application I have built. In my unit tests I …

c# unit-testing mocking httpcontext
Returning value that was passed into a method

I have a method on an interface: string DoSomething(string whatever); I want to mock this with MOQ, so that …

c# mocking moq
jquery (or pure js) simulate enter key pressed for testing

What the best way to simulate the user pressing "enter"? $(element).keypress() doesn't seem to allow me to pass in …

javascript jquery testing mocking
Faking an RS232 Serial Port

I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports. …

windows mocking serial-port hardware-interface virtual-serial-port
Unfinished Stubbing Detected in Mockito

I am getting following exception while running the tests. I am using Mockito for mocking. The hints mentioned by Mockito …

java mocking mockito