Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- = junit
- [2017-07-18 19:01]
- * spring本体
- ** @RunWith(SpringRunner.class)
- ** @ContextConfiguration
- nested @Configuration classes within your test
- ** @WebAppConfiguration
- WebApplicationContext
- file:src/main/webapp
- ** @TestExecutionListeners
- ** @TestPropertySource
- ** @ActiveProfiles("unittest")
- * springboot
- Spring Boot application is just a Spring ApplicationContext
- ** @SpringBootTest
- @ContextConfiguration の代わり
- SpringApplication のテスト用
- ** Spring Boot’s @*Test annotations will search for your primary configuration automatically
- テストクラスのパッケージ配下の @SpringBootApplication, @SpringBootConfiguration を探す
- ** nested @TestConfiguration class
- テスト固有設定追加用
- ** @TestComponent @TestConfiguration annotation
- src/test/java に置く
- テスト用に除外する場合に使用する
- ** @WebMvcTest
- spring mvc controller テスト用
- ** stdout キャプチャ
- @Rule
- public OutputCapture capture = newOutputCapture();
- * bootなし dbunit spock
- @DbUnitConfiguration(dataSetLoader=XlsDataSetLoader.class)
- @ContextConfiguration(classes = TestWebApplication.class)
- @TestExecutionListeners([ DependencyInjectionTestExecutionListener.class,
- DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class,
- DbUnitTestExecutionListener.class ])
- class KokyakuInfoRegistryInitInsertInputTest001 extends AbstractDBExportBaseSpec{
- @ExpectedDatabase(value = "KokyakuInfoRegistryTest001_expected.xlsx", table = "local.t_kokyaku", columnFilters=[MyFilter.class], assertionMode=DatabaseAssertionMode.NON_STRICT,
- query = "select * from local.t_kokyaku where kokyaku_no = (select max(kokyaku_no) from local.t_kokyaku)")
- okyaku where kokyaku_no = (select max(kokyaku_no) from local.t_kokyaku)")
- @Unroll("case001_001顧客情報新規入力")
- def "顧客情報新規入力を行う"() {
- * boot transaction dbunit mockuser
- @RunWith(SpringRunner.class)
- // ここからだとテスト環境DBをアクセスしてしまうのでローカルに設定
- @SpringBootTest(properties = { "spring.datasource.url=jdbc:postgresql://localhost/postgres",
- "spring.datasource.password=postgres" })
- // 以下だけでは設定不足のため上記 SpringBootTestをつかう
- // @ContextConfiguration(classes = {TestWebApplication.class, ShitenUserSearchServiceTest.Config.class})
- // @SpringBootApplication(scanBasePackages = { "jp.co.nii", "jp.co.livemax" })
- @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class,
- WithSecurityContextTestExecutionListener.class })
- @DbUnitConfiguration(dataSetLoader = XlsDataSetLoader.class)
- @Transactional
- @Rollback(true)
- @Test
- @WithMockCustomUser(userId = "1")
- // @WithUserDetails(value = "sakuma", userDetailsServiceBeanName = "kikanUserDetailsService")
- // @Sql("ShitenUserSearchServiceTest.sql")
- @DatabaseSetup(value = "ShitenUserSearchServiceTest.xlsx", type = DatabaseOperation.REFRESH)
- * bootなし inner config
- @Configuration
- @ComponentScan(basePackages = { "jp.co.nii.fw", "jp.co.livemax.common" })
- @PropertySource("classpath:application.properties")
- public static class Config {
- @Bean
- public ShitenUserSearchService shitenUserSearchService() {
- return new ShitenUserSearchService();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement