I did parameterization. Is there any way I can only run some parameters in the parameter group when running a testcase #10858
Unanswered
wang1150297847
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Hi @wang1150297847 , From what I understand, you need randomness in your parameterization. import pytest
import random
parameters = [(1,11),(2,22),(4,44)]
number_of_param_selected = random.randint(1, len(parameters))
randomized_parameters = random.choice(parameters, k=number_of_param_selected)
@pytest.mark.parametrize("num, output", randomized_parameters)
def test_multiplication_11(num, output):
assert 11*num == output |
Beta Was this translation helpful? Give feedback.
3 replies
-
Please outline why you want to limit that specific parameter so a fitting suggestion can be done |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@pytest.mark.parametrize("case_lel,id,", [('P0',0),('P1',1),('P2',2)])
#demo.py
class TestClass_A:
def test_demo(self,case_lel,id):
print(id)
now: pytest demo.py::TestClass_A::test_demo
it will run parameters ('P0',0) , ('P1',1) and ('P2',2)
can somtime I run only one set of parameters?
eg:i just use ('P0',0) or i use ('P0',0) , ('P1',1)
can run like this ? pytest demo.py::TestClass_A::test_demo::parametrize['P0','P1']
Or is there any other way to achieve the functions I need
Beta Was this translation helpful? Give feedback.
All reactions