Virtual mock

Virtual mock

Virtual Mocks are a way to mimic the behavior of real objects in a controlled way. A computer programmer typically creates virtual mocks to test the behavior of some other object just like mock objects, although Virtual Mocks can be used to mock concrete classes.

Reasons for use

The reasons are the same reasons as mock objects. The only difference is the scope. While mock objects can only mock interfaces, virtual mocks can mock any classes (real objects)

Technical details

Virtual Mocks use aspect-oriented programming techniques to intercept the regular flow of the code, allowing a client object to remain unaware of whether it is using a real object or a mock object. Available virtual mock frameworks allow the programmer to specify which methods will be invoked on a mock object and what parameters will be passed to them, as well as what values will be returned. Thus, the behavior of a complex object such as a network socket can be mimicked by a mock object, allowing the programmer to discover whether the object being tested responds appropriately to the wide variety of states such objects may be in.

Use in test-driven development

Although one benefit of test-driven development is the creation of loosely coupled code, too many interfaces can make the code complex and hard to understand. In addition to enabling the mocking of interfaces, Virtual Mock also allows the programmer not to decouple the code and mock classes (real objects). This minimizes the need to design for testing.

See also

Mock object

* [http://code.google.com/p/moq/ Moq]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Mock — may refer to: In geography: Mock, California, in Inyo County In programming: Virtual mock or Mock object, simulated objects that mimics the behavior of real objects in controlled ways In mathematics: Mock modular form, mathematical function In… …   Wikipedia

  • Virtual jury research — is a technique used by lawyers to prepare for trial.For many decades, attorneys have employed jury consultants to conduct jury research to help prepare for trial. The goals of such research vary: to assess the case and to discover its primary… …   Wikipedia

  • Virtual Engineering — im Anlagenbau am Virtual Dimension Center Als Virtual Engineering (VE) (deutsch etwa Virtuelle Entwicklung technischer Systeme) bezeichnet man die Unterstützung von Entwicklungsprozessen mit Hilfe digitaler, dreidimensionaler Modelle.… …   Deutsch Wikipedia

  • DjUnit — is an Eclipse plug in that generates code coverage reports, tests with mock objects, and provides simple trace information about test cases. djUnit plugin is JUnit TestRunner with the custom classloader. djUnit ClassLoader modifies class in… …   Wikipedia

  • Eurocopter EC175 — Infobox Aircraft name= EC175 caption= type= Medium utility helicopter manufacturer= Eurocopter Harbin Aircraft Industry Group (HAIG) designer= first flight= 2011 introduced= 2012 retired= status= primary user= more users= produced= number built=… …   Wikipedia

  • Claustrophobia — This article is about the fear of enclosed spaces. For 2004 film, see Claustrophobia (2004 film). For 2008 film, see Claustrophobia (2008 film). Getting caught in a small hole, due to cave ins or suddenly finding the den of a dangerous animal,… …   Wikipedia

  • April Fools Day 2008 — April 1, 2008 was an April Fools Day falling on a Tuesday. In newspapers, magazines and news websites * About.com s Car Reviews posted a fake story that Toyota had announced a new 256 horsepower V6 Prius to accommodate the needs of car buyers… …   Wikipedia

  • CM Punk — Ring name(s) CM Punk …   Wikipedia

  • Washington and Lee University — Infobox University name = Washington and Lee University motto = Non Incautus Futuri Latin: Not Unmindful of the Future established = 1749 type = Private university endowment = US $693.0 million president= Kenneth Patrick Ruscio city = Lexington… …   Wikipedia

  • Libraries and Museums — ▪ 2007 Introduction Libraries and museums grappled with ways to attract more patrons during the year, introducing innovative software (Library 2.0), technological wizardry (iPods as museum aides), and even “bib dating.” Efforts continued to… …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”