Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用特定的活动概要文件和上下文配置等参数以编程方式运行TestNG类_Java_Spring_Testng - Fatal编程技术网

Java 使用特定的活动概要文件和上下文配置等参数以编程方式运行TestNG类

Java 使用特定的活动概要文件和上下文配置等参数以编程方式运行TestNG类,java,spring,testng,Java,Spring,Testng,我有一个从AbstractTestNGSpringContextTests扩展而来的集成测试类。我想运行两次测试类,每次都以编程方式使用不同的概要文件,而不是通过硬编码概要文件和配置xml,如下所示 @ContextConfiguration(locations = { "classpath:MyBatisBeanConfiguration.xml" }) @ActiveProfiles("cloud") public class MyIntegrationTests extends Abstr

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

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

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


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

可能会有所帮助。谢谢@RC。同时,我认为我需要进入spring测试框架的代码库,看看它如何使用特定的概要文件执行testNG测试。