import junit.framework.TestCase;
public class FractionTest extends TestCase {
public void testAddition() {
Fraction half = new Fraction(2, 4);
Fraction fourth = new Fraction(1, 4);
Fraction actual = half.add(fourth);
Fraction expected = new Fraction(3, 4);
assertEquals(expected, actual);
}
public void testSubtraction() {
Fraction half = new Fraction(2, 4);
Fraction fourth = new Fraction(1, 4);
Fraction actual = half.subtract(fourth);
Fraction expected = fourth;
assertEquals(expected, actual);
}
public void testAddNumberToItself() {
Fraction half = new Fraction(2, 4);
Fraction actual = half.add(half);
Fraction expected = new Fraction(1, 1);
assertEquals(expected, actual);
}
}
Notice the duplication of code. Duplication of code is bad!