Parameterized unit tests is a feature of some unit testing frameworks. It supports executing a given unit test multiple times with different arguments.
Questions tagged [parameterized-unit-test]
116 questions
1
vote
1 answer
How to fix the error "Receiver class org.junit.jupiter.engine.descriptor.TestTemplateExtensionContext does not define or inherit an implementation"?
I have the following parameterized JUnit5 test that is supposed to take input data from the method testData
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSSigner;
import…

ScrewTheWest
- 13
- 3
1
vote
1 answer
Indirect parameterization with multiple parametrize decorators in pytest
First of all sorry in advance if I'm doing this wrong, this is my first question asked on stackoverflow. So please let me know if my formulation is off.
So I'm working on a project where I want to unit test a pipeline which calls multiple function…

gigibeau
- 13
- 2
1
vote
1 answer
Unit test conditional statements using environment variable
I have a source file util.py and there I have below one, where day is an AWS lambda environment variable.
import os
day = os.getenv("DAY")
def get_day_code():
if day == "Monday":
return "M"
if day == "Tuesday":
return "T"
…

Praveen
- 31
- 3
1
vote
1 answer
C++ Google Type-Parameterized and Value-Parameterized Tests combined?
I would like to be able to parameterize my tests for various types through the following code snippet:
template
class MyTestSuite : public testing::TestWithParam>, T, T>>
{
public:
MyTestSuite()
{
…

Kok How Teh
- 3,298
- 6
- 47
- 85
1
vote
1 answer
Why have to initialize all variables again in Parameterized JUnitTest although they are intialize in @Before method or at class level
I have one parametrized Junit test in my class. If I initialize all objects used in this test in @Before method they are not accessible in this parametrized Junit test and it throws NUllPointer Exception, due to which I have to initialize all theses…

Umair
- 585
- 3
- 9
- 21
1
vote
1 answer
How to run @RunWith(RobolectricTestRunner::class) and @RunWith(Parameterized::class) together in Junit4
I have to test android application written in Kotlin. I tried
@RunWith(RobolectricTestRunner::class)
public class GeoWindowTest {
@RunWith(Parameterized::class)
class TestParameterizedGeoWindow {}
}
but it doesnt work. Im looking…

Mahriban
- 31
- 3
1
vote
1 answer
Using an array of testinfra_hosts, can you control the parametrized values used for each host in a test?
I'm trying to write a test suite for verifying the state of some servers using testinfra.
It's my first time working with python/testinfra/pytest.
As a brief pseudocodey example
test_files.py
testinfra_hosts=[server1,server2,server3]
with…

granthouston44
- 13
- 3
1
vote
2 answers
How to group test data in a parameterized test?
I'm working on an application which has a grid and only some points of the grid are considered valid. I need to test this extensively with all possible grid values or at least with all the boundary points.
I've tried out parameterized tests. It…

Kalarani
- 407
- 4
- 11
1
vote
0 answers
Pytest testing KeyError exception while using parameterize
I am using the @pytest.mark.parametrizefunctionality to test multiple test cases using pytest. Now I am having a hard time understanding how do I test if my function throws a KeyError by default, how do I write a test for it?
In the example below,…

Samarth
- 242
- 2
- 12
1
vote
1 answer
Parameterized tests with JUnitParamsRunner for Mockito.verify() of different methods
So, I have a method that takes an Object parameter and depending on its value invokes different methods (I use just if statements instead of switch).
public class ClassToTest {
public void methodToTest(String input) {
if…

Alish_strong
- 99
- 1
- 8
1
vote
2 answers
Paramterized Testing with Junit
How can I test the following method with parameterized testing in JUnit
public class Math {
public static int add(int a, int b) {
return a + b;
}
}
I wish to know how parameterized testing with Junit will be implemented to test…

user722781
- 121
- 1
- 1
- 3
1
vote
1 answer
What is the best practice to write parameterized tests for validating string inputs?
I'm writing a parameterized unit test for a code something similar to below, to make sure that my tests cover all the possible input cases and the system behaves as expected.
I came up with 3 approaches i.e. testGetAnimalMood1, testGetAnimalMood2,…

canan
- 63
- 1
- 7
1
vote
1 answer
Can multidimensional arrays be passed via @MethodSource (junit 5.1)?
I'm trying to pass two-dimensional arrays to a parameterized test. The one-dimensional array works as expected, but junit complains on the second with "Error resolving parameter at index 0". Is this not supported or am I using the wrong syntax?…

Tamás
- 91
- 5
1
vote
1 answer
How to parameterize xpath and parse it as a text?
I have a python file, Base.Py
def provideElectricJobDetails(self):
self.ui.driver.find_element_by_name("Title").send_keys("Test")
self.ui.driver.find_element_by_xpath("//span[contains(text(),'Select AOR...')]").click()
…

Sidharth Gokul
- 111
- 1
- 6
- 14
1
vote
0 answers
JUnit Parameterized Tests Dynamic Loaded List
I have a list of products, each of which have its own list of catalogues. The available catalogues are not the same for every product. I´d love to parameterize this Suite, in a way that testing each catalogue is a test case, but have until now only…

Enrique Castaneda
- 135
- 1
- 10