forked from junit-team/junit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameterizedMigrationDemo.java
More file actions
101 lines (80 loc) · 2.18 KB
/
ParameterizedMigrationDemo.java
File metadata and controls
101 lines (80 loc) · 2.18 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright 2015-2025 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/
package example;
import java.util.Arrays;
import org.junit.jupiter.params.AfterParameterizedClassInvocation;
import org.junit.jupiter.params.BeforeParameterizedClassInvocation;
import org.junit.jupiter.params.ParameterizedClass;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
public class ParameterizedMigrationDemo {
@SuppressWarnings("JUnitMalformedDeclaration")
// tag::before[]
@RunWith(Parameterized.class)
// end::before[]
public
// tag::before[]
static class JUnit4ParameterizedClassTests {
@Parameterized.Parameters
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] { { 1, "foo" }, { 2, "bar" } });
}
// end::before[]
@SuppressWarnings("DefaultAnnotationParam")
// tag::before[]
@Parameterized.Parameter(0)
public int number;
@Parameterized.Parameter(1)
public String text;
@Parameterized.BeforeParam
public static void before(int number, String text) {
}
@Parameterized.AfterParam
public static void after() {
}
@org.junit.Test
public void someTest() {
}
@org.junit.Test
public void anotherTest() {
}
}
// end::before[]
@SuppressWarnings("JUnitMalformedDeclaration")
// tag::after[]
@ParameterizedClass
@MethodSource("data")
// end::after[]
static
// tag::after[]
class JupiterParameterizedClassTests {
static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] { { 1, "foo" }, { 2, "bar" } });
}
@org.junit.jupiter.params.Parameter(0)
int number;
@org.junit.jupiter.params.Parameter(1)
String text;
@BeforeParameterizedClassInvocation
static void before(int number, String text) {
}
@AfterParameterizedClassInvocation
static void after() {
}
@org.junit.jupiter.api.Test
void someTest() {
}
@org.junit.jupiter.api.Test
void anotherTest() {
}
}
// end::after[]
}