2017-02-16 126 views
0

其實從@Christoph所有建議的代碼不給答案 不知從克里斯托弗解釋是有效的測試場景出現,但測試類CitrusFramework CustomAction沒有在測試失敗的測試用例結果

試驗後

@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"); 
     } 
    } 

所以這個配置產生以下 - 請注意它的測試成功報告?!?!

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%) 

回答

0

這是因爲您處於JUnit或TestNG的測試後階段。這在技術上不再是柑橘測試的一部分。您應該在Citrus中使用* AfterTestSupport類,如下所述:http://www.citrusframework.org/reference/html/test-suite.html#after-test。只有這樣你才能訪問Citrus中的測試變量和測試邊界。

+0

仍然沒有好評@Override \t public void afterTest(TestRunner runner){FailAction action = new FailAction(); \t action.setMessage(「ERROR」); \t runner.run(action); }'我在報告INFO nnerAfterTestSupport中得到這個,event name:output WARN citrus.TestCase |測試失敗後出現錯誤 com.consol.citrus.exceptions.TestCaseFailedException:測試用例失敗citrus.Citrus |試用後:成功 citrus.Citrus | citrus.Citrus | CITRUS測試結果 FlowTestCase.flowTestItemUpdateMessage SUCCESS – user3499805

+0

您必須使用柑橘上下文中的XML bean定義將AfterTestSupport類添加到Spring應用程序上下文中 ' 或者通過Java的Spring bean配置 '@Bean 公共SequenceAfterTest afterTest(){ 返回新MyAfterTestSupport(); }' –

相關問題