Citrusframework - Java action - Get result

六月ゝ 毕业季﹏ 提交于 2019-12-25 03:15:09

问题


Besides REST-API Calls, I need to call my own Java-Class, which basically does something, which I want to confirm later in the test via REST-API-Calls.

When calling my Java-Class, there is an expected behavior: It may fail or not fail, depending on the actual Test-Case.

Is there any chance to code this expectation this into my test-class:

java("com.org.xyz.App").method("run").methodArgs(args).build();

As this is the Main-Class, which should be executed later in a automated fashion, I would prefer to validate the Return-Code. However, I'm looking for any possible way (Exception-Assertion, Stdout-Check, ..) to verify the status of the program.


回答1:


As you are using the Java DSL to write test cases I would suggest to go with custom test action implementation and/or initializing your custom class directly in the test method and call the method as you would do with any other API.

You can wrap the custom code in a custom AbstractTestAction implementation as you then have access to the TestContext and your custom code is integrated into the test action sequence.

The java("com.org.xyz.App").method("run").methodArgs(args) API is just for compliance to the XML DSL where you do not have the opportunity to initialize own Java class instances. Way too complicated for your requirement in my opinion.



来源:https://stackoverflow.com/questions/53177259/citrusframework-java-action-get-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!