-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_3.java
More file actions
35 lines (28 loc) · 1.04 KB
/
task_3.java
File metadata and controls
35 lines (28 loc) · 1.04 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
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class) // Аннотация для параметризованных тестов
public class CheckIsAdultTest {
private final int age;
private final boolean result;
public CheckIsAdultTest(int age, boolean result) {
this.age = age;
this.result = result; // Инициализация полей
}
@Parameterized.Parameters // Аннотация для параметров
public static Object[][] getTextData() {
return new Object[][] {
{19, true},
{18, true},
{17, false},
{21, true},
};
}
@Test
public void checkIsAdultWhenAgeThenResult() {
Program program = new Program();
boolean isAdult = program.checkIsAdult(age);
assertEquals("Ожидалось " + result + " при возрасте " + age, result, isAdult);
}
}