Quantcast
Channel: What's the difference between a mock & stub? - Stack Overflow
Browsing all 43 articles
Browse latest View live

Answer by kk1 for What's the difference between a mock & stub?

There a lots of greats answers, and I liked this one, so I turned it into a table.DummyStubMockFakeAPIOOOOStatesXOOOValuesXXOOBehaviorXXXO

View Article


Image may be NSFW.
Clik here to view.

Answer by Murat Yıldız for What's the difference between a mock & stub?

StubA stub is an object that holds predefined data and uses it to answer calls during tests. It is used when you can’t or don’t want to involve objects that would answer with real data or have...

View Article


Image may be NSFW.
Clik here to view.

Answer by mostafa kazemi for What's the difference between a mock & stub?

Mocks: help to emulate and examine outcoming interactions. These interactionsare calls the SUT makes to its dependencies to change their state.Stubs: help to emulate incoming interactions. These...

View Article

Answer by DeeFisher for What's the difference between a mock & stub?

StubA stub is an object used to fake a method that has pre-programmed behavior. You may want to use this instead of an existing method in order to avoid unwanted side-effects (e.g. a stub could make a...

View Article

Answer by Lho Ben for What's the difference between a mock & stub?

A stub is a test double that returns values to the SUT. A mock is a test double that a test uses to verify that the SUT correctly invokes a dependency. Also, a mock is often a stub

View Article


Answer by Ahmed Nabil for What's the difference between a mock & stub?

Plus useful answers, One of the most powerful point of using Mocks than SubsIf the collaborator [which the main code depend on it] is not under our control (e.g. from a third-party library),In this...

View Article

Answer by Afonso Matos for What's the difference between a mock & stub?

I was reading The Art of Unit Testing, and stumbled upon the following definition:A fake is a generic term that can be used to describe either a stub or a mock object (handwritten or otherwise),...

View Article

Answer by davidxxx for What's the difference between a mock & stub?

A mock is both a technical and a functional object. The mock is technical. It is indeed created by a mocking library (EasyMock, JMockit and more recently Mockito are known for these) thanks to byte...

View Article


Answer by Developer for What's the difference between a mock & stub?

Both Stubs and Mocks override external dependencies but the difference isStubs -> To Test DataMocks -> To Test BehaviorA quote from Fowler's Mocks Aren't Stubs article:Stubs provide canned...

View Article


Answer by Mikayil Abdullayev for What's the difference between a mock & stub?

Say you have a class named EmployeeService that you want to test and that has one dependency on an interface named EmployeeDao:public class EmployeeService{ private EmployeeDao dao; public...

View Article

Answer by Moshisho for What's the difference between a mock & stub?

Using a mental model really helped me understand this, rather than all of the explanations and articles, that didn't quite "sink in".Imagine your kid has a glass plate on the table and he starts...

View Article

Answer by William Entriken for What's the difference between a mock & stub?

A test subject performs actions in response to certain prompts (function calls) or other stimuli. Here are concrete examples of test situations.Scenario -- EMT student examA student has studied to be...

View Article

Answer by Alireza Rahmani Khalili for What's the difference between a mock &...

let see Test Doubles:Fake: Fakes are objects that have working implementations, but not the same as production one. Such as: in-memory implementation of Data Access Object or Repository. Stub: Stub is...

View Article


Answer by Relu Mesaros for What's the difference between a mock & stub?

Stubs vs. MocksStubs provide specific answers to methods callsex: myStubbedService.getValues() just return a String needed by the code under testused by code under test to isolate itcannot fail testex:...

View Article

Answer by Kasper for What's the difference between a mock & stub?

a lot of valid answers up there but I think worth to mention this form uncle bob:https://8thlight.com/blog/uncle-bob/2014/05/14/TheLittleMocker.htmlthe best explanation ever with examples!

View Article


Answer by Premraj for What's the difference between a mock & stub?

The generic term he uses is a Test Double (think stunt double). Test Double is a generic term for any case where you replace a production object for testing purposes. There are various kinds of double...

View Article

Answer by Didier A. for What's the difference between a mock & stub?

Mock - A mock intercepts a call to a method or function (or a group of methods and functions like in the case of a mocked class). It is not an alternative to that method or function. In that...

View Article


Image may be NSFW.
Clik here to view.

Answer by Aviram Fireberger for What's the difference between a mock & stub?

This slide explain the main differences very good.*From CSE 403 Lecture 16 , University of Washington (slide created by "Marty Stepp")

View Article

Answer by A.I for What's the difference between a mock & stub?

I came across this interesting article by UncleBob The Little Mocker. It explains all the terminology in a very easy to understand manner, so its useful for beginners. Martin Fowlers article is a hard...

View Article

Answer by simon.denel for What's the difference between a mock & stub?

A stub is a fake object built for test purposes. A mock is a stub that records whether expected calls effectively occurred.

View Article
Browsing all 43 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>