Questions tagged [parametrized-testing]
91 questions
                    
                    19
                    
            votes
                
                3 answers
            
        Use pure Kotlin function as Junit5 methodsource
I am curious if in the Kotlin, in the parameterized tests in Junit5, i can use the method outside the class as the @MethodSource.
I know about 2 ways to use @MethodSource in Kotlin - companion object and…
         
    
    
        Failed
        
- 228
- 2
- 8
                    18
                    
            votes
                
                5 answers
            
        How to properly return a list from a pytest fixture for use in parametrize?
I am attempting to build a little pytest test to ensure all expected keys exist in redis. I have a list of expected keys, that I am storing as a YML file. The test itself will query against redis to ensure each of the expected keys from the list…
         
    
    
        NewGuy
        
- 3,273
- 7
- 43
- 61
                    5
                    
            votes
                
                2 answers
            
        What's the difference between / advantage of using JUnit 5's @ParametrizedTest over @TestFactory Stream? 
        First, what do they mean by this in the conclusion of Guide to Dynamic Tests in Junit 5?
The parameterized tests can replace many of the examples in this article. However, the dynamic tests differ from the parameterized tests as they support full…
         
    
    
        Andrew Cheong
        
- 29,362
- 15
- 90
- 145
                    4
                    
            votes
                
                2 answers
            
        How to write Nested ParametrizedTest with MethodSource in Kotlin?
I'm learning how to write test in Kotlin with JUnit 5. I like using feature like @Nested, @ParametrizedTest and @MethodSource when I was writing Java. But when I switch to Kotlin, I encounter an issue:
I figured out how to use
@Nested by referring…
         
    
    
        samabcde
        
- 6,988
- 2
- 25
- 41
                    4
                    
            votes
                
                1 answer
            
        pytest: use fixture with pandas dataframe for parametrization
I have a fixture, which returns a pd.DataFrame. I need to insert the individual columns (pd.Series) into a unit test and I would like to use parametrize.
Here's a toy example without parametrize. Every column of the dataframe will be tested…
         
    
    
        Andi
        
- 3,196
- 2
- 24
- 44
                    4
                    
            votes
                
                2 answers
            
        Parametrizing multiple tests dynamically in Python
I'm attempting to use Pytest to write a dynamic test suite, where the test data is held in a separate file, e.g. a YAML file or a .csv. I want to run multiple tests, all of which are parameterised from the same file. Let's say I have a testing file…
         
    
    
        Lou
        
- 2,200
- 2
- 33
- 66
                    4
                    
            votes
                
                2 answers
            
        marking a test as xfail with double parameterize in pytest
I have a pytest test that tests several inputs against two different databases.
i do it with using the parameterized mark twice:
@pytest.mark.parametrize(
    "input_type",
    [
        pytest.param("input_1"),
        pytest.param("input_2"),
   …
         
    
    
        EytanGro
        
- 65
- 5
                    4
                    
            votes
                
                1 answer
            
        How to define display name using nested attributes of arguments in ParameterizedTest(name = #{index} multiply {0[0]} x {0[1]} = {0[2]})
I cannot figure out if it is a missing feature, see the JUnit issue 1154 and my comment there, or just my inability to write properly the syntax for name of the @ParameterizedTest in JUnit5. Given the fact that issue has been open for last 3 years,…
         
    
    
        DelphyM
        
- 322
- 2
- 14
                    4
                    
            votes
                
                0 answers
            
        Why does using pytest-asyncio and @parametrize cause tests to run for longer than without
I have a test. It sends a get request to a list of urls and checks that the response is not 500. 
    @pytest.mark.asyncio
    @pytest.mark.parametrize('url_test_list', get_all_url_list(HOST_FOR_TEST))
    async def test_check_status_urls(self,…
         
    
    
        Anton
        
- 41
- 2
                    3
                    
            votes
                
                2 answers
            
        How to skip parametrized tests with pytest
Is it possible to conditionally skip parametrized tests?Here's an example:
@pytest.mark.parametrize("a_date", a_list_of_dates)
@pytest.mark.skipif(a_date > date.today())
def test_something_using_a_date(self, a_date):
    assert 
Of… 
         
    
    
        Jonathan Livni
        
- 101,334
- 104
- 266
- 359
                    3
                    
            votes
                
                2 answers
            
        How to use `fixture` and `parametrize` to set environmental variable for pytest tests
I have pytest tests which result may depend on environmental variable. I want to test them for multiple values of this environmental variable.
I want to have only one fixture which sets this environment variable but I want to be able to configure…
         
    
    
        Karol Zlot
        
- 2,887
- 2
- 20
- 37
                    3
                    
            votes
                
                1 answer
            
        Is it possible to @mark.parametrize twice one test?
I have multiple functions which raise ValueError to test. So far my solution is:
import pytest
import record
@pytest.fixture(name='raised')
def is_value_error_raised(func, args):
    try:
        func(*args)
        return True
    except…
         
    
    
        Ethr
        
- 431
- 1
- 3
- 17
                    3
                    
            votes
                
                1 answer
            
        PyTest : dynamically generating test name during runtime
I want to name the test dynamically during run-time when i run them with the @pytest.mark.parametrize("value",values_list) fixture.
for example:
values_list=['apple','tomatoes','potatoes']
@pytest.mark.parametrize("value",values_list)
def…
         
    
    
        Bored002
        
- 353
- 6
- 18
                    3
                    
            votes
                
                1 answer
            
        How run parametrize test only once in pytest
I need to run only once  parametrized test in pytest, 
for example I've got a  dynamic list with test data and want to run test with test_data[0]  parameters in case user send some condition for this, like mark
test_data = list()
test_data =…
         
    
    
        Boris Becker
        
- 31
- 2
                    2
                    
            votes
                
                2 answers
            
        How can I use the transformed data from the fixture for parameterization within the current test?
I have next code for pytest:
import pytest
@pytest.fixture
def my_fixture():
  def _method(a_list):
    return [num*0.5 for num in a_list]
  return _method
# @pytest.mark.parametrize ??
def test_me(my_fixture):
    pre_list = [0, 3, 1, 2]
   …
         
    
    
        KarimovAnton
        
- 25
- 3