-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCatTest.java
More file actions
32 lines (25 loc) · 822 Bytes
/
CatTest.java
File metadata and controls
32 lines (25 loc) · 822 Bytes
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
package com.example;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class CatTest extends TestCase {
@Mock
Feline feline;
@Test
public void testGetSound() {
var cat = new Cat (feline);
assertEquals("Мяу", cat.getSound());
}
@Test
public void testGetFood() throws Exception {
when(feline.eatMeat()).thenReturn(List.of("Животные", "Птицы", "Рыба"));
var cat = new Cat (feline);
assertEquals(List.of("Животные", "Птицы", "Рыба"),cat.getFood());
}
}