Examination hints

Figure 566. Personal examination cheat sheets Slide presentation Create comment in forum

Figure 567. Unit tests in examinations Slide presentation Create comment in forum
  • Task definitions by Javadoc.

  • Corresponding Unit tests.

  • Automated evaluation scoring your achievements.

  • Individual weights reflecting a test's significance.


Figure 568. Example interface definition Slide presentation Create comment in forum
/**
* Finde das n-te ungerade Element einer Wertefolge.
* 
* <p>Beispiel: Im Array {3, 2, 0, 1, 4} ist der Wert «1» an der Index-
*   position «3» das zweite ungerade Element.</p>
* 
* @param werte Die zu durchsuchenden Werte.
* @param n Die gewünschte Position, Start bei 1.
* 
* @return Den Index des n-ten ungeraden Wertes falls es mindestens n
* ungerade Werte gibt, ...
*/
static public int getNtesUngeradesElement(final int[] werte, final int n){     
    return 12345; // TODO: Implementiere mich korrekt!
}

Figure 569. Corresponding test Slide presentation Create comment in forum
@Test
@Marking(points=1) /* 1 point if test passes */
public void test_400() {
  Assert.assertEquals(
    2, /* Expected result */
    Helper.getNtesUngeradesElement(new int[]{-4,  6,  1, -2,   8}, 1));
}

Figure 570. Unit tests strategy in examinations Slide presentation Create comment in forum
  • Unit testing is relentless: You are no longer at high school where a result having just a wrong sign used to matter next to nothing.

  • Focus on completing units of work rather than nearly finishing a large number of tasks.

  • Watching a test fail just happens. Learn to systematically fix bugs:

    1. Use your IDE's debugger. Practise debugging Junit tests individually addressing failures one by one.

    2. Insert log statements using log4j.