Hello,

Je débute dans le dev Java et je tente sans succès de réaliser un test.
J'ai des erreurs sur les méthodes "when" et "thenreturn " qui me disent :

The method "when" and "thenReturn"(Player) is undefined for the type PlayerPronoTest
sachant que " PlayerPronoTest " est le nom de la classe de mes tests unitaires

Voici mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
package com.apside.prono.test;
 
import org.junit.Before;
 
import static org.junit.Assert.assertNotNull;
 
import java.util.Date;
 
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
import com.apside.prono.model.Player;
import com.apside.prono.repository.PlayerRepository;
import com.apside.prono.service.PlayerService;
 
@RunWith(SpringJUnit4ClassRunner.class)
 
public class PlayerPronoTest {
 
	@Mock
	private PlayerRepository playerRepository;
 
	@InjectMocks
	private PlayerService playerService;
 
 
	@Before
	public void init() {
	    MockitoAnnotations.initMocks(this);
	}
 
	@Test
	public void canGetPlayerById(Player player) {
		when(playerService.getPlayerById(2L))thenReturn(player);
 
		assertNotNull(player);
		}
	}
Vous remerciant pour votre aide