[TIP] Selecting test Item at run time

arun kali raja arunsep886 at gmail.com
Mon Nov 27 08:18:14 PST 2017


Hi,

Currently pytest creates an item object for each of the testcase and then
puts them in a list. During run phase it serially pics one item after the
other and runs the testcases one after the other.

I have a requirement where the next testcase to run has to be chosen
dynamically based on the pass or fail criteria of the previous testcase..

Say i logically arrange by testcases in a tree structure like below:

[image: Inline images 4]
So if Test_A passed then test_B can be executed or else Test_C has to be
executed. And so forth..


There could be a scenarios:

1. where say i may have to run a single level for multiple iterations to
verify if i am getting a stable result at a particular level.

2. Say through some internal logic i selected Test_H and it has failed. I
may now decide to run Test_F and see if it passes.

pytest_runtest_teardown And seems to get the nextItem directly so how to
control what is the nextItem to be executed.Is there any existing hook i
can use to do this.. Or can i implement a new hook to do such things???
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20171127/df16cd2f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 33470 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20171127/df16cd2f/attachment-0001.png>


More information about the testing-in-python mailing list