일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Windows 10
- xargs
- Mac
- port
- netsh
- Windows
- profile
- 단축키
- bash
- Quartz
- find
- plugin
- maVen
- GIT
- grep
- context
- IntelliJ
- 네트워크
- 줄바꿈 문자
- import
- resource
- ssh
- VirtualBox
- tomcat
- Eclipse
- vscode
- Source
- JavaScript
- lsof
- web.xml
- Today
- Total
develog
JUnit Parameterized Test 본문
package test;
import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class CalculatorTest {
Calculator cal;
private int num1;
private int num2;
public CalculatorTest(int num1, int num2) {
this.num1 = num1;
this.num2 = num2;
}
@Parameters
public static Collection<Object[]> data() {
Object[][] data = new Object[][] {
{1, 2}
, {2, 3}
};
return Arrays.asList(data);
}
@Before
public void before() {
cal = new Calculator();
}
@Test
public void testSum() {
assertEquals(num1 + num2, cal.sum(num1, num2));
}
}
'Dev > junit' 카테고리의 다른 글
spring 2.5 에서는 junit 4.4 버전 사용 (0) | 2012.12.05 |
---|---|
JUnit 4 Test Suite (0) | 2012.12.02 |
JUnit4 hamcrest (0) | 2012.11.28 |
JUnit 4 Assert (0) | 2012.11.07 |
[junit] JUnit 4 Annotations (0) | 2012.11.07 |