I want to fail a test but it's not working

Hi ,

I ‘m using robot framework version 3.2.1
I’m trying to fail the test by using in the end_keyword method this commnad BuiltIn().set_test_variable(’${TEST STATUS}’, step_status)

when i open the log in the web browser i see that the test passed

please advise

Thanks in advance,

Avi

Hi Avi, welcome in Robot Framework Forum.

${TEST STATUS} is most likely read-only.

If you want to fail a test, use Fail keyword.

Regards

Thanks Markus but now only in the console is see the errors but in the log the test pass!
you can see the log screenshot i’ve attached

You seems to use a listener to fail it.
This would have been a vital information.
Please describe a bit more about your use case.

If you use a Listener V3 it should be possible to manipulate the result object of the keyword itself instead of calling a fail keyword or raise an error, what would be the same.
Because in this case your listener fails, not the test.

i tried to use the prebotmodifer flag i thougt it might help instead of the listener . the listenser didnn’t work as mentioned)

like this :

‘’’’ robot.run(‘Tests\Common\infraTest.robot’, variable=‘sut:new_sut_test_example’, listener=‘Tools/PublisherListener.py’,prerebotmodifier=‘Tools/premodifier.py’)

‘’’’’’

I have a file called premodifier.py with visit_test and visit_suite methods but when debugging i can see that the debugger doesn’t enter this file

what am i doing wrong ?

Hi Rene,

I use listener version 2 . i’m using the end_keyword method to fail the test .
i’ve attached a screenshot of the method

You should have a look to the end_test of listener v3

i think you could use it.

thanks

i want to fail a keyword ( i use the the keywords to represnt steps)
Thats why i’m using end_keyword and not end_test

Is it ok ?

Yes.
In listener v3 you could manipulate the test result. Not a keyword result.

yes i read about it now . what about to use the prebotmodifier , will it solve my problem ?

Difficult to say.

My initial question would be: why is it not possible to fail the keyword itself?

because it not failing the step in the log as you can see in the screenshot

no i mean, why can not the keyword itself fail.
What is the “Use Case” of the listener.

Could you explain the problem a bit better?
I understand, that raising an Error in Listener does not Fail a step!
But this is how you try to fix your problem.
What was your problem?