CitrusFramework CustomAction在测试结果中的测试用例没有失败

时间:2017-02-16 13:43:38

标签: junit junit4 citrus-framework

实际上来自@Christoph的所有建议代码都没有给出答案 以某种方式来自Christoph的解释在测试场景之前是有效的,但在测试之后则没有。

    @Configuration
    public class AppConfig {

    @Bean(name="correlationId")
    public String getCorrelationId() {
        return RandomNumberFunction.getRandomNumber(48, false);
    }

    @Bean
    @DependsOn("correlationId")
    public SequenceAfterTest afterTest() {
        return new KrampCitrusTestRunnerAfterTestSupport();
    }

    @Bean
    @DependsOn("correlationId")
    public SequenceBeforeTest  beforeTest() {
        return new KrampCitrusTestRunnerBeforeTestSupport();
     }
    }

考试后的课程

    public class KrampCitrusTestRunnerAfterTestSupport
        extends TestRunnerAfterTestSupport {


    @Override
    public void afterTest(TestRunner runner) {

         runner.echo("This action should be executed after each test");
         runner.fail("message");
      }
    }

所以这个配置会产生以下结果 - 请注意它的TEST SUCESS报告?!?!

14:19:50,900 INFO         citrus.Citrus| 
14:19:50,901 INFO         citrus.Citrus| 
14:19:50,903 WARN       citrus.TestCase| After test failed with errors
com.consol.citrus.exceptions.TestCaseFailedException: Test case failed
    at com.consol.citrus.TestCase.executeAction(TestCase.java:236)
    at com.consol.citrus.dsl.runner.DefaultTestRunner.run(DefaultTestRunner.java:198)
    at com.consol.citrus.dsl.runner.DefaultTestRunner.fail(DefaultTestRunner.java:265)
    at com.kramp.eai.test.common.iibexception.KrampCitrusTestRunnerAfterTestSupport.afterTest(KrampCitrusTestRunnerAfterTestSupport.java:45)
    at com.consol.citrus.dsl.runner.TestRunnerAfterTestSupport.doExecute(TestRunnerAfterTestSupport.java:48)
    at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
    at com.consol.citrus.TestCase.afterTest(TestCase.java:203)....
    Caused by: com.consol.citrus.exceptions.CitrusRuntimeException: message
at com.consol.citrus.actions.FailAction.doExecute(FailAction.java:40)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.TestCase.executeAction(TestCase.java:229)
... 31 more
14:19:50,917 INFO         citrus.Citrus| 
14:19:50,917 INFO         citrus.Citrus| -----------------------------------
 -------------------------------------
14:19:50,917 INFO         citrus.Citrus| 
14:19:50,918 INFO         citrus.Citrus| 
14:19:50,918 INFO         citrus.Citrus| AFTER TEST SUITE: SUCCESS
14:19:50,918 INFO         citrus.Citrus| -----------------------------------
-------------------------------------
14:19:50,918 INFO         citrus.Citrus| 
14:19:50,918 INFO         citrus.Citrus| -----------------------------------
-------------------------------------
14:19:50,918 INFO         citrus.Citrus| 
14:19:50,918 INFO         citrus.Citrus| CITRUS TEST RESULTS
14:19:50,918 INFO         citrus.Citrus| 
14:19:50,924 INFO         citrus.Citrus|  TC12: CDM............................... SUCCESS
14:19:50,924 INFO         citrus.Citrus| 
14:19:50,924 INFO         citrus.Citrus| TOTAL: 1
14:19:50,924 INFO         citrus.Citrus| FAILED:    0 (0.0%)

1 个答案:

答案 0 :(得分:0)

这是因为您处于JUnit或TestNG的后测试阶段。这在技术上不再是柑橘测试的一部分。您应该在Citrus中使用* AfterTestSupport类,如下所述:http://www.citrusframework.org/reference/html/test-suite.html#after-test。只有这样,您才能访问Citrus中的测试变量和测试边界。