Testing on the Toilet

July 24, 2008

Testing Against Interfaces To quell a lingering feeling of inadequacy, you took the time to build your own planetary death ray, a veritable rite of passage in the engineering profession. Congratulations. And you were feeling pretty proud until the following weekend, when you purchased the limited-edition Star Wars trilogy with Ewok commentary, and upon watching the Death Star destroy Alderaan, you realized that you had made a bad decision: Your planetary death ray has a blue laser, but green lasers look so much cooler. But it's not a simple matter of going down to Radio Shack to purchase a green laser that you can swap into your existing death ray. You're going to have to build another planetary death ray from the ground-up to have a green laser, which is fine by you because owning two death rays instead of one will only make the neighbors more jealous. Both your planetary death rays should interoperate with a variety of other bed-wettingly awesome technology, so it's natural that they export the same Java API: public interface PlanetaryDeathRay { public void aim(double xPosition, double yPosition); public boolean fire(); /* call this if she says the rebel base is on Dantooine */ } public class BlueLaserPlanetaryDeathRay implements PlanetaryDeathRay { /* implementation here */ } public class GreenLaserPlanetaryDeathRay implements PlanetaryDeathRay { /* implementation here */ }

Testing both death rays is important so there are no major malfunctions, like destroying Omicron Persei VIII instead of Omicron Persei VII. You want to run the same tests against both implementations to ensure that they exhibit the same behavior – something you could easily do if you only once defined tests that run against any PlanetaryDeathRay implementation. Start by writing the following abstract class that extends junit.framework.TestCase and belongs to a build rule that includes java/junit as a dependency: public abstract class PlanetaryDeathRayTestCase extends TestCase { protected PlanetaryDeathRay deathRay; @Override protected void setUp() { deathRay = createDeathRay(); } @Override protected void tearDown() { deathRay = null; } protected abstract PlanetaryDeathRay createDeathRay(); /* create the PlanetaryDeathRay to test */ public void testAim() { /* write implementation-independent tests here against deathRay.aim() */ } public void testFire() { /* write implementation-independent tests here against deathRay.fire() */ } }

Note that the setUp method gets the particular PlanetaryDeathRay implementation to test from the abstract createDeathRay method. A subclass needs to implement only this method to create a complete test: the testAim and testFire methods it inherits will be part of the test when it runs: public class BlueLaserPlanetaryDeathRayTest extends PlanetaryDeathRayTestCase { protected PlanetaryDeathRay createDeathRay() { return new BlueLaserPlanetaryDeathRay(); } }

You can easily add new tests to this class to test functionality specific to BlueLaserPlanetaryDeathRay.

More information, discussion, and archives: http://googletesting.blogspot.com Copyright © 2007 Google, Inc. Licensed under a Creative Commons Attribution–ShareAlike 2.5 License (http://creativecommons.org/licenses/by-sa/2.5/).

Testing Against Interfaces Code

Jul 24, 2008 - Page 1 ... inadequacy, you took the time to build your own planetary death ray, a veritable ... build rule that includes java/junit as a dependency:.

141KB Sizes 2 Downloads 233 Views

Recommend Documents

Testing sensory evidence against mnemonic ... - Semantic Scholar
Dec 14, 2015 - To track the temporal evolution of task-relevant coding (i.e., the ...... tracker (SR research, EyeLink 1000, sampling one eye at 1000 Hz, .... inverse. Since both the design matrix and the estimated weight matrix were of full rank, th

The case against standardized testing - teacherrenewal
everyone has ulterior motives for testing, of course. ... But the testing process is nothing at all like, say, measuring the size or weight of an object. .... The parts of standardized exams that deal with science or social studies, meanwhile, typica

Testing sensory evidence against mnemonic templates - eLife
14 Dec 2015 - In the sim- plest case, increasing baseline activity of a stimulus-specific representation could boost target processing (Sylvester et al., 2009). This boost ..... Figure 4. Cross-temporal generalization of orientation decoding. (A) Tun

The case against standardized testing - teacherrenewal
"A" in SAT used to stand for Aptitude until the Educational Testing Service gave up this pretense. .... Even if the tests are imperfect, don't top students still do the best? .... More important, even if the top 10 percent did a lot better than the b

Testing sensory evidence against mnemonic ... - Semantic Scholar
Dec 14, 2015 - file for template information in the MEG data (Figure 3C). Next .... Additional files ..... Sylvester CM, Shulman GL, Jack AI, Corbetta M. 2009.

Remote Testing of International Interfaces with Teachers
May 10, 2012 - educational tools they use every day. They are eager to ... SMART Technologies. 3636 Research Road NW ... using educational technology.

Remote Testing of International Interfaces with ...
Keywords. Remote Testing, Low Cost Usability, Internationalization ... Skype and GotoMeeting can be used with usability ... phone that we can call them at.

Extracting Methods to Simplify Testing Code
Jun 13, 2007 - BicycleRepairMan, and in Java by several IDEs, including IntelliJ IDEA and Eclipse.) More information, discussion, and archives:.

testing for a unit root against transitional ... - Wiley Online Library
performance of the standard unit root test against transitional AR models has been reported by many studies, including Balke and Fomby (1997), Taylor (2001), ...

Electrical properties of III-V/oxide interfaces interfaces
Interface states arise from the sudden disruption of the lattice structure, which creates carrier energy levels different from the usual energy band structure. DOS ..... m s. G. C. VQ. C. VQ. V. V. )( )( −. −−. +=φφ and respectively. •. Fin

interfaces
ing a satellite broadband communication system. NATIVE has played an .... it provides an excellent overview of many environ- mental issues as they relate to ...

CoGenTe: A Tool for Code Generator Testing
Sep 24, 2010 - rating various coverage criteria over semantics. This enables ... tactic aspects of a translation, but its complex semantic as- pects, too. Syntactic ...

Behaviour Directed Testing of Auto-code Generators
[19] G. C. Necula. Translation validation for an optimizing com- piler. In PLDI, pages 83–94, 2000. [20] V. Paxson. flex - A fast scanner generator., 2.5 edition,.

Be an MVP of GUI Testing Code
Feb 5, 2009 - MVP is very similar to MVC (Model-View-Controller). In MVC, the presentation logic is shared by Controller and. View,as shown in the diagram ...

Collaborative User Interfaces
Nov 20, 2008 - time-critical situations. In this case, a chat or a video conference is more ... rative interfaces, that have different solutions to problems. In the next.

KUKA youBot Hardware Interfaces - GitHub
youBot hardware. omni-directional mobile platform.. 5-degree-of-freedom manipulator.. 2-finger gripper. all joints with relative encoders. real-time ...

Interfaces de Audio.pdf
AES 11 o DARS (Digital Audio Reference Signal). 1. INTERCONEXIÓN SDIF-2/3 (Sony Digital Interface):. DSD (Direct Stream Digital) es el nombre acuñado por ...

MATERIALS AND INTERFACES Solubilization of ...
Vp, of the sand bed was 0.42, calculated according to the following ... (C14TAB), (c) nonylphenyl ethoxylates (NP-n), and (d) sodium dodecyl sulfate (SDS).

Radiotelephones having contact-sensitive user interfaces and ...
Mar 11, 2005 - cause the display or the radio-telephone communications transceiver to perform a ..... menu or a list of telephone numbers that are stored in the.

MATERIALS AND INTERFACES Solubilization of ...
interestingly, however, results from batch and column experiments reveal that the interactions between surfactant ... E-mail: [email protected]. MSR ) (S ...