0

我有一个从 AbstractTestNGSpringContextTests 扩展的集成测试类。我想运行测试类两次,每次以编程方式使用不同的配置文件,而不是通过硬编码配置文件和配置 xml,如下所示。

@ContextConfiguration(locations = { "classpath:MyBatisBeanConfiguration.xml" })
@ActiveProfiles("cloud")
public class MyIntegrationTests extends AbstractTestNGSpringContextTests
{
  @Test
  public void myTest()
  {
   //do something
  }
}
4

1 回答 1

0

您可以使用 VM 参数 spring.profiles.active 在您的测试(或任何其他应用程序)中启用某些弹簧配置文件。

例子:-Dspring.profiles.active=cloud,someOtherProfile

于 2013-07-03T18:36:27.760 回答