質問編集履歴

2

テストケースで@MockBeanを使用していたため反映しました。

2021/10/21 06:22

投稿

katatema01
katatema01

スコア23

test CHANGED
File without changes
test CHANGED
@@ -24,9 +24,15 @@
24
24
 
25
25
 
26
26
 
27
+ @MockBean TestService testService;
28
+
29
+
30
+
27
31
  @Test
28
32
 
29
33
  void 試験その1() {
34
+
35
+ when(testService.check(any()).thenReturn(true);
30
36
 
31
37
  mvc.perform(get("/test")).andExpect(status().isOK);
32
38
 
@@ -50,11 +56,17 @@
50
56
 
51
57
  @Autowired public MockMVC moc;
52
58
 
59
+
60
+
53
-
61
+ @MockBean SampleService sampleService;
62
+
63
+
54
64
 
55
65
  @Test
56
66
 
57
67
  void 試験その2() {
68
+
69
+ when(sampleService.check(any()).thenReturn(true);
58
70
 
59
71
  mvc.perform(get("/samples")).andExpect(status().isOK);
60
72
 

1

所感追記

2021/10/21 06:22

投稿

katatema01
katatema01

スコア23

test CHANGED
File without changes
test CHANGED
@@ -129,3 +129,7 @@
129
129
  どなたか、このケースの回避方法をご存知の方はいらっしゃいますでしょうか?
130
130
 
131
131
  せめてテストクラスごとにSpringBootをShutDownしてコネクションを開放できれば良いと考えております。
132
+
133
+
134
+
135
+ どうも、HikariCPのshutdownがJVMの終了にフックされている様な気もする。。。