Questions tagged [parametrized-testing]

91 questions
0
votes
0 answers

JUnit parametized tests failing randomly

I have a following parametrized test @ParameterizedTest @ValueSource(strings = { "[1;1f[?25l", "[K[K\n", "[0m 8 [48;2;142;142;142m[38;2;0;0;0m ♜ [48;2;204;204;204m[38;2;0;0;0m ♞…
TomKo1
  • 214
  • 2
  • 14
0
votes
1 answer

How to use correctly assertThrows on set of values?

I've been learning Java just for a bit, so please advise how exception throwing test should look like in this case? I have following Gambling Machine Class. And then 2 tests for it. I do not really know what should follow the "Integer" in second…
Veronique
  • 23
  • 7
0
votes
1 answer

How to parameterize exceptions in JUnit5 with hemcrest?

i want to test all different exceptions with one parameterized test using hemcrest for one method. So that means that Exception1.class, Exception2.class should be parameters. How do i parameterize them, and do it by using hemcrest?
0
votes
0 answers

accessing request.fspath for generating parameters for a test

I know it's impossible to add more tests inside fixtures because they run at test time, and tests are generated at collection time. But I want to be able to generate parameters to a test based on the path to the test function (to the module where…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
0
votes
1 answer

pytest: Parametrizing from function output / from directory structure

I am trying to build testcase parameters and expected outputs from a directory structure. The directory structure is as follows: __init__.py foo.py testing/ ├── test_foo/ │   ├── __init__.py │   ├── case-0001/ │   │   ├── input_1.json │   │   ├──…
0
votes
1 answer

junit 5 custom parametrized tests

I'm using Junit 5 parametrized tests with custom name as follow @ParameterizedTest(name = PARAMETERIZED_TESTS_NAME_PLACEHOLDER) where PARAMETERIZED_TESTS_NAME_PLACEHOLDER is defined in its own utility class public static final String…
bolbol
  • 77
  • 10
0
votes
1 answer

pytest, parametrize x in first list and y in second list

xlist = ["url1", "url2", "url3"] ylist = ["xp1", "xp2", "xp3"] @pytest.mark.parametrize("url, xp", [(xlist, ylist)]) class Test01: def test_001(self, url, xp): print(url) print(xp) Result: Process finished with exit code…
Awave
  • 7
  • 5
0
votes
1 answer

Setting up the test execution sequence in conftest.py of pytest, parametrized testing

conftest.py: def pytest_collection_modifyitems(config, items): def param_part(item): # check for the wanted module and test class if item.nodeid.startswith("test_urls.py::TestSSL::"): # find the start of the parameter…
0
votes
1 answer

Pytest - how to order test execution in parametrized tests by parameter first

I have the following parametrized test: import pytest @pytest.mark.parametrize("url1", ["url0001", "url0002", "url0003"], indirect=False) class Test01: def test01(self, url1): print(url1) assert url1 == f"{url1}" def…
0
votes
1 answer

Is there an option to generate dynamically n tests in Spock

I have a file with n lines. In my Spock test, I download, read the file, and assert each line of it. Is there a way to produce n tests in the report instead of a one?
pixel
  • 24,905
  • 36
  • 149
  • 251
0
votes
1 answer

How to escape double qootes in Junit 5 a ParametrizedTest with CsvFileSource

When using @ParametrizedTest in Junit 5 with @CsvFileSource, i need a parameter containing double quotes. How do I escape these, i.e. how do i pass exatly "a test" as my parameter? What I have tried: "a test" ""a test"" \"a test\" "\"a test\"" What…
user2727133
  • 149
  • 1
  • 12
0
votes
1 answer

Pytest parametrize with dynamic values

I would like to run test several times according to given list. I build the list according to a given file at the 'setup_module' section. Is it possible to do something like this? data = [] def setup_module(module): with open('data.json') as…
Avi Elgal
  • 149
  • 1
  • 3
  • 9
0
votes
1 answer

How can i pass N number of variables for testing in parameterized googletest?

I am using gtest for unit testing. I have to call a lot to arrays to test. But I am not figuring out how i can pass N - number of variables in 'INSTANTIATE_TEST_CASE_P' to test. I have simply created two arrays array1 and array2 and I am passing…
0
votes
1 answer

Parametrized JUnit Test with @MethodSource with method that returns an ArrayList

I want to implement a paramterized JUnit test for a method, that has three input parameters. I want the test to run through the cartesian product of all possible combinations of these three input parameters. For this, I have a method, that generates…
YourReflection
  • 375
  • 7
  • 22
0
votes
1 answer

JUnit: Run same test on multiple target classes

I'm trying to automate a way to grade multiple students' files at once in my intro to Java class. How can I run the same test(s) on all the files in a folder assuming the following conditions are true: All files exist in the same folder (no…
mpcsf
  • 1
  • 1