Run Keyword and Expect Error, how to expect one of several errors?

4,019 views
Skip to first unread message

Pether Pettersson

unread,
Aug 7, 2015, 9:10:46 AM8/7/15
to robotframework-users
Is it possible to expect several errors? I have tried using list variables to no avail.
I need to be able to check if the Keyword runs into one of several possible exceptions.

If i try to use a list all it says is that there are no Keywords with the name of an error i want to look for

Run Keyword and Expect Error  Meow  Keyword        # Works as it's only one Error
Run Keyword and Expect Error @{errors}  Keyword   # Doesn't work, claims no keyword with the name of the second item in the list

Hélio Guilherme

unread,
Aug 8, 2015, 2:40:56 AM8/8/15
to robotframework-users
A possible solution is for you to create a keyword that calls `Run Keyword And Ignore Error` which obtains the error message (or keyword result), and then you would test the error message.

What are the error conditions you expect? A list of errors that must occur, or a list of possible errors?

Pether Pettersson

unread,
Aug 8, 2015, 3:45:06 AM8/8/15
to robotframework-users
Hi,

I am creating test cases that i am using to debug communication with an MCU. When i communicate i get responses, if i send a faulty message i am supposed to get error codes back, i want to catch the error codes that i want to happen, seeing as it responds as i want.
How i have structured this up is that i read the communication, if i don't get a proper message, i send it to a parser that checks the error codes and raises an exception containing the error in text instead of bytes, making it easier to read. I want to catch these exceptions in robot framework, instead of for example, in the python code. 

So it's errors, exceptions, that must occur for the test to PASS.

GAURAV DEORE

unread,
Aug 9, 2015, 11:40:02 PM8/9/15
to petterss...@gmail.com, robotframework-users
Pether,

Try with "Run Keyword And Continue On Failure" keyword. if you want to test multiple options then you must have to FOR loop. in to that you can use this keyword.
It will log run time error separately.



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
------------------------------
Warm Regards,
GAURAV S. DEORE.

Pether Pettersson

unread,
Aug 10, 2015, 2:10:32 AM8/10/15
to robotframework-users, petterss...@gmail.com
I don't think that will work for my test. I am using one keyword, and can receive one of several errors, which will come i don't know, only that one of those will(should) come.


On Monday, August 10, 2015 at 5:40:02 AM UTC+2, Gaurav Deore wrote:
Pether,

Try with "Run Keyword And Continue On Failure" keyword. if you want to test multiple options then you must have to FOR loop. in to that you can use this keyword.
It will log run time error separately.


On Sat, Aug 8, 2015 at 1:15 PM, Pether Pettersson <petterss...@gmail.com> wrote:
Hi,

I am creating test cases that i am using to debug communication with an MCU. When i communicate i get responses, if i send a faulty message i am supposed to get error codes back, i want to catch the error codes that i want to happen, seeing as it responds as i want.
How i have structured this up is that i read the communication, if i don't get a proper message, i send it to a parser that checks the error codes and raises an exception containing the error in text instead of bytes, making it easier to read. I want to catch these exceptions in robot framework, instead of for example, in the python code. 

So it's errors, exceptions, that must occur for the test to PASS.

On Saturday, August 8, 2015 at 8:40:56 AM UTC+2, Hélio Guilherme wrote:
A possible solution is for you to create a keyword that calls `Run Keyword And Ignore Error` which obtains the error message (or keyword result), and then you would test the error message.

What are the error conditions you expect? A list of errors that must occur, or a list of possible errors?

sexta-feira, 7 de Agosto de 2015 às 14:10:46 UTC+1, Pether Pettersson escreveu:
Is it possible to expect several errors? I have tried using list variables to no avail.
I need to be able to check if the Keyword runs into one of several possible exceptions.

If i try to use a list all it says is that there are no Keywords with the name of an error i want to look for

Run Keyword and Expect Error  Meow  Keyword        # Works as it's only one Error
Run Keyword and Expect Error @{errors}  Keyword   # Doesn't work, claims no keyword with the name of the second item in the list

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages