Created
March 15, 2019 12:02
-
-
Save j4rv/2cfa584b1df0d082906d5b782c128a6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(Parameterized.class) | |
public class CalculatorTest { | |
enum Type {SUBSTRACT, ADD}; | |
@Parameters | |
public static Collection<Object[]> data(){ | |
return Arrays.asList(new Object[][] { | |
{Type.SUBSTRACT, 3.0, 2.0, 1.0}, | |
{Type.ADD, 23.0, 5.0, 28.0} | |
}); | |
} | |
private Type type; | |
private Double a, b, expected; | |
public CalculatorTest(Type type, Double a, Double b, Double expected){ | |
this.type = type; | |
this.a=a; this.b=b; this.expected=expected; | |
} | |
@Test | |
public void testAdd(){ | |
Assume.assumeTrue(type == Type.ADD); | |
assertEquals(expected, Calculator.add(a, b)); | |
} | |
@Test | |
public void testSubstract(){ | |
Assume.assumeTrue(type == Type.SUBSTRACT); | |
assertEquals(expected, Calculator.substract(a, b)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment