-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLionNoParamTest.java
More file actions
39 lines (32 loc) · 1.29 KB
/
LionNoParamTest.java
File metadata and controls
39 lines (32 loc) · 1.29 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
package com.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class LionNoParamTest {
@Mock
Feline feline;
@Test
public void testGetFood() throws Exception {
when(feline.getFood("Хищник")).thenReturn(List.of("Животные", "Птицы", "Рыба"));
var lion = new Lion("Самец", feline);
assertEquals(List.of("Животные", "Птицы", "Рыба"),lion.getFood());
}
@Test
public void testGetKittens() throws Exception {
when(feline.getKittens()).thenReturn(2);
var lion = new Lion("Самец", feline);
assertEquals(2,lion.getKittens());
}
@Test
public void testException() throws Exception {
Exception exception = assertThrows(Exception.class, () -> new Lion("Неопределенный", feline));
assertEquals("Используйте допустимые значения пола животного - самец или самка", exception.getMessage());
}
}