SpringBootのアプリケーションをテストする際には以下のように書きますが、
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SpringBootConfig.class)
public class HogeServiceTest {
}
特定のテストの時だけ、一部プロパティを上書きしたいような場合は次のように書くと便利かもしれません。
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { SpringBootConfig.class, HogeServiceTest.class })
@Configuration
@PropertySource(value = "classpath:/override.properties")
public class HogeServiceTest {
}
override.propertiesには、変更したいプロパティだけを書いておきます。