문제

I have a keyword implemented with Java and if keyword fails i need to stop the whole test execution with message: "ERROR: example message".

도움이 되었습니까?

해결책

Take a look at the user guide under Reporting keyword status:

You may throw any exception in the keyword method. The exception type will be used as prefix and you can add a message as well.

다른 팁

Raising exceptions is the officially recommended way.

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#reporting-keyword-status

Java (as there in the comment to accepted answer)

throw new AssertionError("ERROR: example message")

Python

from exceptions import AssertionError
.
.
.
 def rftest(self):
   test_result = lib.runtest()
   if (0 != test_result ):
          raise AssertionError("Test Failed")

I see 2 solutions for this:

  • First solution:

In the test itself you can use

Library         Dialogs
(....)
pause execution     myMessage

which will show a popup on the screen and pause the execution until the OK button is called. You can, for instance return a specific value from the java keyword in case of error and pause if that value is returned.

  • Second Solution

I prefer this one: just connect a debugger to the java code which executes the keyword and stop when an exception occurs. It also allows to inspect the state of the JVM at that moment. This post shows how to do connect a remote debugger to the jvm which runs the robot keyword.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top