将测试套件作为休息服务公开时无法关闭 CITRUS SPRING IOC 容器

Unable to close CITRUS SPRING IOC container while exposing the test suite as a rest service

我正在使用 TESTNG 执行 CITRUS 测试 class,同时执行以下柑橘代码正常执行并且它在最后关闭 spring 容器。

TestNG testng = new TestNG();
    List<String> suites = Lists.newArrayList();
    suites.add("C:/Users/mounika/citrusrest/CitrusDemoServices/src/test/java/com/citrus/samples/TestSuit.xml");//path to testng xml..
    testng.setTestSuites(suites);
    testng.run();

测试 class 执行正常,但在将上述代码公开为 rest 服务时,citrus spring 容器未关闭。通常,虽然 运行 通常没有在最后暴露于休息服务,但我得到以下日志

 18:26:08.459 [Thread-0] INFO 
org.springframework.context.support.GenericApplicationContext - Closing 
org.springframework.context.support.GenericApplicationContext@6b1274d2: 
startup date [Mon Nov 27 18:26:02 IST 2017]; root of context hierarchy
18:26:08.459 [Thread-0] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Returning cached instance of singleton bean 'lifecycleProcessor'
18:26:08.459 [Thread-0] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Destroying singletons in org.springframework.beans.factory.support.
DefaultListableBeanFactory@25d250c6: defining beans 
[org.springframework.context.annotation.
internalConfigurationAnnotationProcessor,org.springframework.context.
annotation.internalAutowiredAnnotationProcessor,org.springframework.
context.annotation.internalRequiredAnnotationProcessor,org.
springframework.
context.annotation.internalCommonAnnotationProcessor,
org.springframework.context.event.internalEventListenerProcessor,
org.springframework.context.event.internalEventListenerFactory,
citrusSpringConfig,com.consol.citrus.functions.FunctionConfig,
functionRegistry,citrusFunctionLibrary,
com.consol.citrus.validation.matcher.ValidationMatcherConfig,
validationMatcherRegistry,xmlValidationMatcher,
citrusValidationMatcherLibrary,
com.consol.citrus.validation.MessageValidatorConfig,
defaultXmlMessageValidator,defaultMessageHeaderValidator,
defaultXpathMessageValidator,defaultJsonMessageValidator,
defaultJsonPathMessageValidator,defaultPlaintextMessageValidator,
defaultBinaryBase64MessageValidator,defaultGzipBinaryBase64MessageValidator,
defaultXhtmlMessageValidator,defaultXhtmlXpathMessageValidator,
defaultGroovyXmlMessageValidator,defaultGroovyJsonMessageValidator,
defaultGroovyTextMessageValidator,citrusMessageValidatorRegistry,
testContextFactory,endpointFactory,referenceResolver,
messageConstructionInterceptors,loggingReporter,htmlReporter,
testListeners,testActionListeners,testSuiteListeners,messageListeners,
failureStackTestListener]; root of factory hierarchy

但是在作为休息服务调用时,由于第一次休息命中后,它没有在最后显示上述日志,在第二次休息命中中,柑橘也在执行相同的 xml 测试用例。我想为每个 Rest 命中更改测试用例 xml 名称。

如果未明确手动关闭,Citrus 中使用的 Spring 应用程序上下文将绑定到 JVM 关闭。如果您的 JVM 运行时终止,Spring 应用程序上下文将自动关闭。

如果您 运行 TestNG 进程作为服务器 JVM 的一部分,只要服务器 运行 就不会终止。所以我看到两个选项供您选择:

  1. 运行 使用 Java 在单独的 JVM 进程中进行测试 java.lang.ProcessBuilder API.
  2. 将一些逻辑添加到执行 a 的后套件 TestNG 阶段 手动正常关闭 Spring 应用程序上下文。