forked from cowille/Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterizedTest.java
More file actions
44 lines (37 loc) · 1.16 KB
/
ParameterizedTest.java
File metadata and controls
44 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
* A sample parameterized test-case.
*
* @version $Id: ParameterizedTest.java 551 2010-03-06 11:37:34Z paranoid12 $
*/
@RunWith(value=Parameterized.class)
public class ParameterizedTest {
private double expected;
private double valueOne;
private double valueTwo;
@Parameters
public static Collection<Integer[]> getTestParameters() {
return Arrays.asList(new Integer[][] {
{2, 1, 1}, //expected, valueOne, valueTwo
{3, 2, 1}, //expected, valueOne, valueTwo
{4, 3, 1}, //expected, valueOne, valueTwo
});
}
public ParameterizedTest(double expected,
double valueOne, double valueTwo) {
this.expected = expected;
this.valueOne = valueOne;
this.valueTwo = valueTwo;
}
@Test
public void sum() {
Calculate calc = new Calculate();
assertEquals(expected, calc.add(valueOne, valueTwo), 0);
}
}