Created
June 1, 2019 05:30
-
-
Save donchan922/d6a7c005dc95134efe30d17b2401ffe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DemoControllerTest { | |
private MockMvc mockMvc; | |
// テスト対象のクラス内で呼び出すクラス(依存クラス)をモック化する | |
@Mock | |
private DemoService demoService; | |
// テスト対象のクラスにモックをインジェクションする | |
@InjectMocks | |
private DemoController demoController; | |
@BeforeEach | |
void setup() { | |
// 各テストの実行前にモックオブジェクトを初期化する | |
MockitoAnnotations.initMocks(this); | |
this.mockMvc = MockMvcBuilders.standaloneSetup(demoController).build(); | |
} | |
@Test | |
void GETでアクセスする() throws Exception { | |
// テスト内容 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment