public void decide(int a, int b, int c, int d, int e, int f) { if (a > b || c > d || e > f) { DoOneThing(); } else { DoAnother(); } // One-letter variable names are used here only because of limited space.} // You should use better names. Do as I say, not as I do. :-)
public void decide(int a, int b, int c, int d, int e, int f) { if (tallerThan(a, b) || harderThan(c, d) || heavierThan(e, f)) { DoOneThing(); } else { DoAnother(); }}boolean tallerThan(int a, int b) { return a > b; } // Note “package scope”boolean harderThan(int c, int d) { return c > d; } // rather than public; JUnitboolean heavierThan(int e, int f) { return e > f; } // tests can access these.
public void testProtanopiaColorMatcherIsDistinguishable() { ColorMatcher colorMatcher = new ColorMatcher(PROTANOPIA); assertFalse(“BLUE and VIOLET are indistinguishable”, colorMatcher.isDistinguishable(Color.BLUE, Color.VIOLET));}
Failure: testProtanopiaColorMatcherIsDistinguishable:Message: BLUE and VIOLET are indistinguishable
Failure: testProtanopiaColorMatcherCannotDistinguishBetweenCertainPairsOfColorsMessage: BLUE and VIOLET should be indistinguishable
For those German-speaking folks among our readers of this English Google Testing Blog we have exciting news: We have just launched the German Testing Blog!
This is a tribute to the fact that the German-speaking software test community is one of the biggest non-english audiences of this blog. The german blog will contain a mix of German versions of postings from this blog as well as unique postings about regional-specific issues from Europe. Some of our biggest engineering offices outside of US are in Europe, e.g. in Switzerland and the UK.
So German speakers around the world check out this new resource for interesting discussions about software test, performance test, load test, and how to create rock-solid software.