Questions tagged [parametrized-testing]
91 questions
2
votes
1 answer
pytest.mark.parametrize a copy of a test case without altering the original
Background
We have a big suite of reusable test cases which we run in different environments. For our suite with test case ...
@pytest.mark.system_a
@pytest.mark.system_b
# ...
@pytest.mark.system_z
test_one_thing_for_current_system():
assert…

Socowi
- 25,550
- 3
- 32
- 54
2
votes
1 answer
pytest mark parametrization with dependency on each other
I'm using pytest for unittests and I would like to parametrize the tests.
I know I can use @pytest.mark.parametrize at class level and at method level.
@pytest.mark.parametrize("param1", [1,2,3,4,5])
class TestXYZ:
…

Wör Du Schnaffzig
- 988
- 5
- 23
2
votes
1 answer
GTest parametrized test unpack Values arguments from array or similar
Having a simple parametrized test with GTest, like for eg:
class Example :public ::testing::TestWithParam> {
};
TEST_P(LeapYearMultipleParametersTests, ChecksIfLeapYear) {
int a = std::get<0>(GetParam());
int b =…

Raffaello
- 1,641
- 15
- 29
2
votes
3 answers
JUnit 5 @ParamterizedTest {arguments} vs {argumentsWithNames} placeholders
I'm using JUnit 5.7.0, IntellijIDEA 2021.1.2 CE, MacOS Catalina 10.15. and don't understand the difference between
ParameterizedTest.ARGUMENTS_PLACEHOLDER and ParameterizedTest.ARGUMENTS_WITH_NAMES_PLACEHOLDER.
According to the javadoc…

Nikita Protskiy
- 75
- 1
- 1
- 5
2
votes
2 answers
Postman parameterized tests with actual values and expected errors for same request
I have request with number of tests cases, same endpoint, different actual values, different expected error messages.
I would like to create parameterized request sending particular value and check particular error message from list with all of the…

Vova
- 3,117
- 2
- 15
- 23
2
votes
1 answer
pytest stack parametrize decorators with dynamic parameters
i'm new to pytest so please bear with me.
i'm trying to use stack parametrize decorators to test multiple combination permutations, but the question is how can i use values from other parametrize decorators in the stack.
i found the following: but…

Tam Nguyen
- 88
- 1
- 8
2
votes
1 answer
JUnit parametrized test with parametrized Spring ApplicationContext configuration
SpringBoot 2.2.11, JUnit 5.
My app has several environments. I have a test that tests some conditions in those environments rather than the application itself.
Therefore I want to reuse the same test method, but run it against different…

Ondra Žižka
- 43,948
- 41
- 217
- 277
2
votes
2 answers
Parametrized tests in pytest with varying marks for different test functions
I am currently trying to use pytest's parameterization feature in the following context:
I have multiple functions that should be tested with a universal set of test cases. Depending on the tested function, the same test case should either pass or…

Jan Joswig
- 693
- 5
- 20
2
votes
1 answer
pytest monkeypatch methods with return values from parametrized method
I'm working on writing some tests for a python app with the pytest framework. I have a problem in one of the tests, which I'm not sure the way it works.
example:
@pytest.mark.parametrize("result, status, xml_err, xml_status",[
…

Kris
- 8,680
- 4
- 39
- 67
2
votes
1 answer
Is it possible to parametrize a @BeforeEach, i.e. invoke a different @BeforeEach depending on a parameter given by each @Test?
I'm trying to write a test class that requires the use of a certain setup. When there's only 1 setup, this is easy with @BeforeEach:
@BeforeEach public void setup() {
// my setup code
}
@Test public void test1() {
// ...
}
@Test public void…

Andrew Cheong
- 29,362
- 15
- 90
- 145
2
votes
1 answer
Maven: No runnable methods on @ParameterizedTest
I have a parameterized test, which is passing normally when running with IntelliJ run test configuration.
But running mvn test on it throws java.lang.Exception: No runnable methods.
All other non-parameterized tests marked with @Test pass normally…

user359698
- 193
- 4
- 11
2
votes
1 answer
How to pass function as pytest parameterize fixture?
How can I pass a function as a parameter in Python? I want to do something like the code below.
My goal is to pass different parameters to test a single function.
def __internal_function(inputs):
a,b,c,d = inputs
new_value_of_b =…

darshpreet narula
- 81
- 1
- 7
2
votes
2 answers
JUnit5 CsvFileSource - escape comma (after double quotes)
I haven't found a way to escape the , character in CSV resource file that is used by CsvFileSource junit5 annotation. Consequently, any string containing comma is cut in half and the second part is never used.
Is there some workaround for…

Jiří Železný
- 31
- 1
- 3
1
vote
1 answer
Problem with using a fixture in pytest parametrize
What is the correct syntax to use my_list fixture with parametrize in pytest?
I would like test_item() to be run 5 times (based on the list returned by my_list fixture)
@pytest.fixture
def my_list():
return [1, 2, 3, 4,…

Jaxx
- 1,355
- 2
- 11
- 19
1
vote
1 answer
Executing Parameterized Playwright Tests in Parallel in Node.JS
I am trying to run Parametrized Playwright tests created with Node.js in Parallel.
SRC: https://playwright.dev/docs/test-parameterize
SRC: https://playwright.dev/docs/test-parallel
However, when I combine the two, the test cases run…

SKR
- 779
- 4
- 17
- 31