by Håvard Rast BlokWhile working with a search quality development team, I was asked to collect information from their result pages across all the supported languages. The aim was to quickly get an overview, and then manually look through them for irr…
A Partial Mock is a mock that uses some behavior from a real object and some from a mock object. It is useful when you need bits of both. One way to implement this is often a Forwarding Object (or wrapper) which forwards calls to a delegate.For example…
With all the sport drug scandals of late, it’s difficult to find good role models these days. However, when your role model is a Domain Model (object model of the business entities), you don’t need to cheat to be an MVP–Use Model-View-Presenter!MVP is…
When scientists in California tried to raise condors in captivity, they ran into a problem. The chicks wouldn’t eat from the researchers’ hands; they wanted a mother condor to feed them. So the scientists got a puppet. To the chicks, it looked like t…
Welcome back! We trust you all had a good holiday season and are ready for more TotTs — DaveMost of us are aware that mock and stub objects can make testing easier by isolating the class under test from external dependencies. This goes hand-in-hand …
Sorry folks, this was a duplicate post. Please see the original here: http://googletesting.blogspot.com/2008/12/mockers-of-c-world-delight.html
No TotT post today.Happy Thanksgiving to all our North American readers.
If you’ve got some multi-threaded code, you may have data races in it. Data races are hard to find and reproduce – usually they will not occur in testing but will fire once a month in production.For example, you ask each of your two interns to bring …
Many modules must access elements of their environment that are too heavyweight for use in tests, for example, the file system or network. To keep tests lightweight, we mock out these elements. But what if no mockable interface is available, or the e…
If your code manipulates floating-point values, your tests will probably involve floating-point values as well.When comparing floating-point values, checking for equality might lead to unexpected results. Rounding errors can lead to a result that is cl…
Sometimes you need to test client-side JavaScript code that uses setTimeout() to do some work in the future. jsUnit contains the Clock.tick() method, which simulates time passing without causing the test to sleep.For example, this function will set up …
[A light hearted episode this week… but still with a serious message. Enjoy. -Dave]HALP! Mah unit tests be doin’ too much I/O! Testin’ this lil’ codes uses MOAR RESOURCES!GIMME lol_io LIKE LOLIOSO IM LIKE PROCESSIN WIT DATAZ OK? GIMME …
When writing a unit test, it is tempting to exercise many scenarios by writing a data-driven test. For example, to test the function IsWord, you could write (ARRAYSIZE is a macro that returns the number of elements in an array):const struct {const char…
You’ve got some code that uses threads, and it’s making your tests flaky and slow. How do you fix it? First, most of the code is probably still single-threaded: test those parts separately. But how to test the threading behavior itself?Often, threaded …
(This week, TotT issued our 100th internally published episode. That’s more than have been published to this Testing Blog — after all, the internal episodes had an 8-month head start, and many would make no sense to readers outside our own stalls — …