Zu testende Methode

public Vektor plus(Vektor that){
    return new Vektor(this.v1+that.v1,this.v2+that.v2,this.v3+that.v3);
}
Java

Anwendung

Vektor v1=new Vektor(1,2,3);
Vektor v2=new Vektor(2,3,5);
Vektor ergebnis=v1.plus(v2);
Java

Prototyp

@Test
public void testPlus() {
    System.out.println("plus");
    Vektor that = null;
    Vektor instance = null;
    Vektor expResult = null;
    Vektor result = instance.plus(that);
    assertEquals(expResult, result);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Java

Angepasster Prototyp

@Test
public void testPlus() {
    System.out.println("plus");
    Vektor that = new Vektor(1,2,3); // Vektor für that erzeugen
    Vektor instance = new Vektor(2,3,5); // unser Vektor
    Vektor expResult = new Vektor(3.0,5.0,8.0); // erwartetes Resultat
    Vektor result = instance.plus(that);
    assertEquals(expResult.toString(),result.toString());
}
Java

Kurzschreibweise

@Test
public void testPlus() {
    System.out.println("plus");
    assertEquals(""+new Vektor(1,2,3).plus(new Vektor(2,3,5)), "(3.0,5.0,8.0)");
}
Java