dimanche 22 octobre 2017

JUnit test classes

I am trying to make a test class for a class that takes two fraction objects and adds/subtracts/multiplies/divides together. Below is the current code I have to test the add method. The test fails and I'm given a message that says:

"Expected MyFraction <Fraction: + 2/5> but was MyFraction <Fraction: + 2/5>"

What am I missing here? Thanks in advance for your help!

@Test
    public void test() {
        MyFraction fracTest1 = new MyFraction(1, 5, '+');
        MyFraction fracTest2 = new MyFraction(1, 5, '+');
        MyFraction fracTest3 = new MyFraction(2, 5, '+');

    assertEquals(fracTest3, fracTest1.add(fracTest2));
}

Aucun commentaire:

Enregistrer un commentaire