Jean-Francois Leveque

Passage à JUnit Jupiter (nouveauté v5)

1 package org.legrog.web.book; 1 package org.legrog.web.book;
2 2
3 import org.junit.Before; 3 import org.junit.Before;
4 -import org.junit.Test; 4 +import org.junit.jupiter.api.Test;
5 +import org.junit.jupiter.api.BeforeEach;
6 +import org.junit.jupiter.api.extension.ExtendWith;
7 +import org.junit.platform.runner.JUnitPlatform;
5 import org.junit.runner.RunWith; 8 import org.junit.runner.RunWith;
6 import org.legrog.entities.Book; 9 import org.legrog.entities.Book;
10 +import org.legrog.test.MockitoExtension;
7 import org.legrog.web.book.BookServiceOld; 11 import org.legrog.web.book.BookServiceOld;
8 import org.mockito.Answers; 12 import org.mockito.Answers;
9 import org.mockito.Mock; 13 import org.mockito.Mock;
...@@ -18,15 +22,16 @@ import java.util.List; ...@@ -18,15 +22,16 @@ import java.util.List;
18 import static org.assertj.core.api.Assertions.assertThat; 22 import static org.assertj.core.api.Assertions.assertThat;
19 23
20 24
21 -@RunWith(MockitoJUnitRunner.class) 25 +@RunWith(JUnitPlatform.class)
22 -public class BookServiceOldTest { 26 +@ExtendWith(MockitoExtension.class)
27 + public class BookServiceOldTest {
23 28
24 @Mock(answer = Answers.RETURNS_DEEP_STUBS) 29 @Mock(answer = Answers.RETURNS_DEEP_STUBS)
25 private EntityManager entityManager; 30 private EntityManager entityManager;
26 31
27 private BookServiceOld bookServiceOld; 32 private BookServiceOld bookServiceOld;
28 33
29 - @Before 34 + @BeforeEach
30 public void setUp() { 35 public void setUp() {
31 bookServiceOld = new BookServiceOld(entityManager); 36 bookServiceOld = new BookServiceOld(entityManager);
32 } 37 }
......
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 import org.junit.Before; 3 import org.junit.Before;
4 -import org.junit.Test; 4 +import org.junit.jupiter.api.Test;
5 import org.junit.jupiter.api.BeforeEach; 5 import org.junit.jupiter.api.BeforeEach;
6 import org.junit.jupiter.api.DisplayName; 6 import org.junit.jupiter.api.DisplayName;
7 import org.junit.jupiter.api.Nested; 7 import org.junit.jupiter.api.Nested;
......
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 -import org.junit.Before; 3 +import org.junit.jupiter.api.BeforeEach;
4 -import org.junit.Test; 4 +import org.junit.jupiter.api.Test;
5 +import org.junit.jupiter.api.extension.ExtendWith;
6 +import org.junit.platform.runner.JUnitPlatform;
5 import org.junit.runner.RunWith; 7 import org.junit.runner.RunWith;
6 import org.junit.jupiter.api.DisplayName; 8 import org.junit.jupiter.api.DisplayName;
7 import org.legrog.entities.Publisher; 9 import org.legrog.entities.Publisher;
8 import org.legrog.entities.PublisherAction; 10 import org.legrog.entities.PublisherAction;
9 import org.legrog.entities.PublisherVersion; 11 import org.legrog.entities.PublisherVersion;
12 +import org.legrog.test.MockitoExtension;
10 import org.mockito.Answers; 13 import org.mockito.Answers;
11 import org.mockito.Mock; 14 import org.mockito.Mock;
12 import org.mockito.Mockito; 15 import org.mockito.Mockito;
...@@ -23,7 +26,8 @@ import static org.mockito.Mockito.*; ...@@ -23,7 +26,8 @@ import static org.mockito.Mockito.*;
23 /** 26 /**
24 * Classe testant ListPublisherVersionsView. 27 * Classe testant ListPublisherVersionsView.
25 */ 28 */
26 -@RunWith(MockitoJUnitRunner.class) 29 +@RunWith(JUnitPlatform.class)
30 +@ExtendWith(MockitoExtension.class)
27 @DisplayName("Listes de versions d'éditeurs") 31 @DisplayName("Listes de versions d'éditeurs")
28 public class ListPublisherVersionsViewTest { 32 public class ListPublisherVersionsViewTest {
29 Logger logger = LoggerFactory.getLogger(getClass()); 33 Logger logger = LoggerFactory.getLogger(getClass());
...@@ -40,7 +44,7 @@ public class ListPublisherVersionsViewTest { ...@@ -40,7 +44,7 @@ public class ListPublisherVersionsViewTest {
40 @Mock(answer = Answers.RETURNS_DEEP_STUBS) 44 @Mock(answer = Answers.RETURNS_DEEP_STUBS)
41 private PublisherService publisherService; 45 private PublisherService publisherService;
42 46
43 - @Before 47 + @BeforeEach
44 public void setUp() { 48 public void setUp() {
45 49
46 // Données 50 // Données
......