Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertTrue;
|
---|
4 |
|
---|
5 | import java.io.IOException;
|
---|
6 | import java.util.Arrays;
|
---|
7 | import java.util.Collection;
|
---|
8 |
|
---|
9 | import org.eclipse.jdt.annotation.NonNull;
|
---|
10 | import org.junit.Test;
|
---|
11 | import org.junit.runner.RunWith;
|
---|
12 | import org.junit.runners.Parameterized;
|
---|
13 | import org.junit.runners.Parameterized.Parameters;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Test to see if getResource can reach the resource file.
|
---|
17 | */
|
---|
18 | @RunWith(Parameterized.class)
|
---|
19 | public class ParameterizedTest {
|
---|
20 |
|
---|
21 | @Parameters
|
---|
22 | public static @NonNull Collection<@NonNull Object[]> data() {
|
---|
23 | return Arrays.asList(new Object[][] { { "ok1" }, { "ok2" } });
|
---|
24 | }
|
---|
25 |
|
---|
26 | private final @NonNull String val;
|
---|
27 |
|
---|
28 | public ParameterizedTest(@NonNull String val) {
|
---|
29 | this.val = val;
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Test
|
---|
33 | public void test1() throws IOException {
|
---|
34 | // would be nice if we can check this is called exactly 2 times
|
---|
35 | assertTrue(val.startsWith("ok"));
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Test
|
---|
39 | public void test_more() throws IOException {
|
---|
40 | assertTrue(val.endsWith("1") | val.endsWith("2"));
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.