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

**URL:** <https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483>\
**Category:** Libraries\
**Created:** [18 July 2020 18:35 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483 "2020-07-18T18:35:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [18 July 2020 18:35 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/1 "2020-07-18T18:35:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Noordsestern](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/noordsestern/32/4270_2.png) [@Noordsestern](https://forum.robotframework.org/u/Noordsestern)\
**Post date:** [18 July 2020 21:28 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/2 "2020-07-18T21:28:23Z")

</div>

Hi Avi, welcome in Robot Framework Forum.

`${TEST STATUS}` [is most likely read-only.](http://robotframework.org/robotframework/3.0/RobotFrameworkUserGuide.html#id514)

If you want to fail a test, [use `Fail` keyword](http://robotframework.org/robotframework/3.0/libraries/BuiltIn.html#Fail).

Regards

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 07:28 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/3 "2020-07-19T07:28:13Z")

</div>

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

 ![log](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/1X/237531cb0176c392fab1fcc9c05f03e97e34b009.jpeg)

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [19 July 2020 08:03 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/4 "2020-07-19T08:03:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 08:55 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/5 "2020-07-19T08:55:39Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 11:25 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/6 "2020-07-19T11:25:39Z")

</div>

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

 ![console](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/1X/e174367561a02f9d310100855f94ed9c132a4d6b.jpeg)

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [19 July 2020 11:51 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/7 "2020-07-19T11:51:01Z")

</div>

You should have a look to the end\_test of listener v3

i think you could use it.

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 11:59 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/8 "2020-07-19T11:59:29Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [19 July 2020 12:00 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/9 "2020-07-19T12:00:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 12:03 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/10 "2020-07-19T12:03:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [19 July 2020 12:05 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/11 "2020-07-19T12:05:13Z")

</div>

Difficult to say.

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

---

<div class="post-metadata">

**Author:** ![aviramb25](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@aviramb25](https://forum.robotframework.org/u/aviramb25)\
**Post date:** [19 July 2020 12:12 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/12 "2020-07-19T12:12:10Z")

</div>

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

 ![log](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/1X/237531cb0176c392fab1fcc9c05f03e97e34b009.jpeg)

---

<div class="post-metadata">

**Author:** ![René](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/ren%C3%A9/32/7_2.png) [@René](https://forum.robotframework.org/u/Ren%C3%A9)\
**Post date:** [28 July 2020 22:34 UTC](https://forum.robotframework.org/t/i-want-to-fail-a-test-but-its-not-working/483/13 "2020-07-28T22:34:49Z")

</div>

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?
