私はspring-boot
のITテストを作成しています。私はここでdev
プロファイルスプリングブートのプロファイルに基づいて選択テストを実行/停止する方法
をアクティブにしたとき
テスト用のデータがapplication-dev.properties
から来ていることは、私はテストのために持っているものです。
@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration
public class ApplicationTests {
@Autowired
Environment env;
@Test
public void contextLoads() {
System.out.println(Arrays.toString((env.getActiveProfiles())));
}
}
ServiceITTest
public class ServiceITTest extends ApplicationTests {
@value
String username;
@value
String address;
@Autowired
MyService myService;
@Test
public void check_for_valid_username_address(){
myService.validate(username,address);
}
}
私は上記をしたいです私が "dev"、 "qa"のプロファイルを設定したときにのみテストを実行します。デフォルトでは実行されません。
春のブートテストでその細かいコントロールを取得することは可能ですか?
これは良いものです。役に立った –