68 questions
2
votes
0
answers
39
views
@ParameterizedTest with @DatabaseSetup and @ExpectedDatabase
I have the following integration test which is setting up the database with @DatabaseSetup and checking that after doStuffThatAffectsTheDb() executes, the db has been modified as expected with @...
0
votes
1
answer
89
views
How can I get the actual type from a generic type parameter
Say, I have an abstract class for testing.
abstract class BaseEntity<SELF extends BaseEntity<SELF>> {
}
I declared an abstract test class for testing subclasses of the BaseEntity.
...
1
vote
0
answers
261
views
How do I enable INSTANTIATE_TEST_SUITE_P in google tests?
I get an errors when trying to work with INSTANTIATE_TEST_SUITE_P.
The minimum non-working example that I got is:
#include "pch.h"
class SimpleTest : public ::testing::TestWithParam<int&...
0
votes
1
answer
203
views
Repeated parameterized test with JUnit 5 / Jupiter
I want to repeatedly execute the following test class:
class Test {
static Foo foo;
@BeforeAll
static void setUpAll() {
foo = generateRandomFoo();
}
@ParameterizedTest
...
1
vote
1
answer
68
views
How to add pytest markers to multiple paramterize
I have the below block of code.
import pytest
@pytest.mark.parametrize("project_name", [
pytest.param("default", marks=pytest.mark.defa),
pytest.param("remote", ...
0
votes
1
answer
36
views
Asserting that a collection is ordered by specific properties passed to test method as parameters
I have a parameterized test with the following property names passed to it:
[TestCase("customerId")]
[TestCase("connectionType")]
public void CanSearchClientsOrderedByProperties(...
5
votes
3
answers
3k
views
Dynamically generate Playwright test asynchronously, shows No test found
The Playwright documentation has a parameterize sample like this. It works:
const people = ['Alice', 'Bob'];
for (const name of people) {
test(`testing with ${name}`, async () => {
// ...
})...
0
votes
1
answer
387
views
How to call junit5 @ParameterizedTest programatically.?
I have a bunch of junit 5 Tests, some of which are Parameterized, and I want to call them from a java class.
The test runs successfully through IDE or using gradle clean build when kept in src/test ...
0
votes
1
answer
2k
views
Json resource value with @ParmetrizedTest , how to add arguments as key value
can i get help with this ?
this my the json file :
{
"1": "1",
"2": "2",
"3": "Fizz",
"4": "4",
"5": ...
0
votes
0
answers
63
views
How to test multiple implementations of a common interface without duplicating the testcode in Go?
How would I streamline the following testing scenario in Go?
Say I have some interface I with a corresponding implementation A and most of my tests for A basically look like:
func TestSomething(t *...
1
vote
1
answer
54
views
How to skip a particular test in parametrized test functions in pytest
I have a pytest function that has markers @pytest.mark.win_11 and @pytest.mark.parametrize('os,result',[('win_11','result1'),('win_8','result2')])
When I run test as 'pytest -m win_11', it is running ...
1
vote
1
answer
293
views
Can't parameterize tests by strings
I'm trying to write a parameterized test based on some string values using the Criterion framework. As an MRE, and following the example shown in the docs, I wrote the following:
#include <...
0
votes
1
answer
58
views
Parameterized JUnit5 Test with all Classes with the same Baseclass
I try to run some tests on all classes that extends the same baseclass like:
classe Baseclass {
abstract int method();
}
class A extends Baseclass { int method(){...} }
class B extends Baseclass {...
0
votes
2
answers
193
views
How can we edit parameter of multiple Jenkins job simultaneously?
I have multiple parameterized Jenkins jobs to run multiple tests. I need to update one parameter of all the Jenkins jobs. Instead of changing the parameters one by one, is there a way to edit all the ...
0
votes
0
answers
20
views
How to feed @ParameterizedTest based on config value [duplicate]
So I have created a parameterized test, which is a simple restassured test which logs into a user account. I have some spring bean config in place, which you can specify a profile to pick up a ...
0
votes
1
answer
1k
views
JUnit 5 Parameterized test @ArgumentsSource parameters not loading
I have created below JUnit5 parameterized test with ArgumentsSource for loading arguments for the test:
public class DemoModelValidationTest {
public ParamsProvider paramsProvider;
public ...
0
votes
1
answer
85
views
JUnit 5, IntelliJ, Maven
i am currently working on a Project with Tests in JUnit 4 and i should migrate them to JUnit 5. Now i have the Problem that i have a Parameterized test in JUnit 4. Lets say my test looks like this:
@...
1
vote
1
answer
3k
views
Junit5 Parameterized Test LifeCycle. why @BeforeAll and static block run after all the tests
I am posting a simple code below, why does @BeforeAll annotated method and static block run after the Parameterized tests? How do I register a common object or Database connection in this case before ...
2
votes
1
answer
2k
views
PyTest Parametrized Test in order
I have 2 pyTest test cases that take a parameter. I want to run them in order with both params, instead of the first test running with all possible values, and then the 2nd test starting.
Consider the ...
0
votes
1
answer
339
views
Why are JUnit5 Parametrized tests using argument providers not defined in @ArgumentSource?
I have a problem with my parameterized tests.
@ParameterizedTest
@ArgumentsSource(CorrectMessagesArgumentProvider.class)
void shouldSendMessageForCorrectConfiguration(SmtpConfiguration ...
8
votes
3
answers
2k
views
How do I parameterize property values for spring boot test
I am working on an aggregation framework using spring boot, which can be used to aggregate multiple kinds of I/O operations' results. Additionally, it has support for both non-blocking (reactive) &...
1
vote
1
answer
3k
views
How to use multiple pytest fixtures with same parameterized input to test methods in a class
I want to achieve something like this:
my conftest.py will contain:
fixture_1 - will do some manipulation with input such as a, b, c using request.param
fixture_2 - will do some manipulation with ...
0
votes
1
answer
2k
views
Dynamically changing @MethodSource in abstract class from a @ParameterizedTest (Jupiter-Junit 5)
I am currently writing unit tests related to GET requests, here below is a parameterized test that take a generic type E.
abstract class AbstractEntityTest< E extends Entity > {
@...
0
votes
1
answer
3k
views
ParametrizedTest with displayName and Argument
I am trying to migrate from JUnit4 to JUnit5 and also I'm new to ParametrizedTest in Junit5 and I have a scenario wherein I would like to provide different DisplayName and the Test argument(Object).
...
2
votes
1
answer
1k
views
Parameterized Test in Kotlin usign mehtod source for nested test class
I may use case the class under test has many cases so it is divided into a structure of inner classes. I want to write parameterized test cases to reduce boiler plate and code duplication.
For this I ...
23
votes
1
answer
18k
views
How to create parameterized test with few enums in JUnit 5?
For example, I have few enums in my project:
Figure, with values TRIANGLE and SQUARE
Color, with values are RED and YELLOW
How to create a test, using the cartesian product of all of the ...
1
vote
1
answer
4k
views
JUNIT @ParameterizedTest , Parameter resolution Exception
Eclipse Version - 4.19.0
Maven Version - 3.8.1
In JUnit I am trying to implement @ParameterizedTest using @CsvSource or @MethodSource. Both are failing due to org.junit.jupiter.api.extension....
1
vote
1
answer
2k
views
JUnit5 - how to pass input collection to ParameterizedTest
I'm trying to translate a ParameterizedTest from JUnit4 to JUnit5 (sadly I'm not particularly skilled in testing).
In JUnit4 I have the following class:
@RunWith(Parameterized.class)
public class ...
1
vote
1
answer
780
views
How do I pass a parameterized value to a pytest fixture?
I'm using pytest to run tests, each with a unique account ID. Each test function requires some setup and teardown, and I switched to using fixtures according to previous suggestions. But now I need to ...
0
votes
0
answers
457
views
How to fix parameters in parameterized test?
I am using gtest for my tests and i am discovering value-parameterized tests.
I understand the google example with
int tab[] = {1, 2, 3};
INSTANTIATE_TEST_CASE_P(MyTestName, MyTest, ::...
1
vote
0
answers
535
views
Mockito Junit jupiter api not resolving the parameter JsonObject
Inorder to get multiple values for test case from JSON file, added the annotation @jsonfilesource and passed JSONObject as parameter to the method in Mockito framework. But I am getting below ...
2
votes
2
answers
2k
views
Is it possible to write parameterized android espresso UI test?
When writing android espresso UI test, is it possible to write parameterized test which accepts data from two different json files to add list of items inside the app?
I have seen parameterized tests ...
0
votes
1
answer
1k
views
How do I include/exclude a JUnit 5 `ParameterizedTest` by name in Maven
I have a parameterized JUnit 5 test, e.g.
@EnumSource(Mode.class)
@ParameterizedTest void shouldRunWithMode(Mode mode) {
...
I want to exclude one of the enum cases from running in Maven, as ...
7
votes
2
answers
26k
views
Use parameterized test returns Method should have no parameters
I have a problem, I would like to pass the test method to send a request using the GET method and POST. I used parameterization, but I get information java.lang.Exception: Method simpleMessage should ...
0
votes
1
answer
348
views
Is it possible to disable one of the valueSource in a parameterizedTest?
I am using JUnit 5 and I have a test case like this:
@ParameterizedTest
@ValueSource(Strings = {a , b , c})
void example(String letter){
// do something
}
the c case is unhandled for now, so is it ...
4
votes
2
answers
3k
views
Data Table tests in Kotlintest - advanced method names and spreading of test cases
I am using Kotlintest and data tables to test an application that uses Kotlin, SpringBoot and Gradle because the syntax is way more concise than ParameterizedJunitTests when you have complex data in ...
1
vote
2
answers
1k
views
Checking exceptions with TestCaseData parameters
I'm using NUnit 3 TestCaseData objects to feed test data to tests and Fluent Assertions library to check exceptions thrown.
Typically my TestCaseData object contains two parameters param1 and param2 ...
4
votes
1
answer
2k
views
Visual Studio 2017 warning for INSTANTIATE_TEST_SUITE_P while using googletest
I have a gtest test fixture for variable parameterized tests and I instantiate the test suite as below:
INSTANTIATE_TEST_SUITE_P(Instantiation, Fixture, ::testing::Range(1, 100));
When I execute the ...
5
votes
1
answer
6k
views
Parameterize @BeforeMethod method in TestNG
I have a base test class for my tests which does the initialisation work before each test.
Here is the code
public class BaseTestParameters {
MyObj myObj;
@DataProvider(name = "apiType")
...
2
votes
1
answer
2k
views
Does Robot Framework support Gherkin data tables?
How can I implement Gherkin data tables in Robot Framework?
The following snippet should pass two sets of (n, is_prime) parameters to Keywords in order to verify that:
is_prime(5) = True
is_prime(6)...
0
votes
1
answer
2k
views
why does it say "The attribute name is undefined for the annotation type Parameterized.Parameters"
I have written a code as follow:
but while compiling it throws the compilation error saying
"The attribute 'name' is undefined for the annotation type
Parameterized.Parameters"
@RunWith(...
0
votes
1
answer
593
views
Mocha paramterized test does not take the modified value of test data array
Here's the simple problem I'm struggling with. In the first example, no tests are run; whereas in the second one, two tests are run as expected.
Does not work as expected: // testData gets populated ...
3
votes
2
answers
8k
views
Java Exception No Tests Found Matching when Junit5 ParameterizedTest Attempt
SO I am trying to use ParameterizedTest from JUnit5 and setup the pom to load everything and now have the following test class.
import static org.hamcrest.MatcherAssert.assertThat;
import static ...
7
votes
1
answer
1k
views
NotAMockException / How to stub a value in parameterized test in Kotlin?
For the following Kotlin class:
class ProductLogic(
private val product: Product?
) {
fun shouldShow(): Boolean {
if (product == null) {
return false
}
...
2
votes
1
answer
315
views
Why is IllegalArgumentException thrown for a Parameterized JUnit test when given List<List<Any>>, but works with List<Array<Any>>
While debugging a Parameterized test, I realized the test wouldn't run if the parameters were passed as a List of Lists (List<List<Any>>), yet worked fine with a List of Arrays (List<...
1
vote
1
answer
1k
views
How to pass multiple parallel streams to Junit5 Parameterized test?
I have two ArrayList<> Objects of equal lengths, and my Junit5 parameterized test has the syntax:
@ParamterizedTest
@MethodSource("dummyfunction");
void functionName(String s1, String s2)
{
.....
....
2
votes
1
answer
1k
views
how to change csvparsersettings of junit parameterized tests using @csvsource
Given a simple test-method, annotated as @ParameterizedTest, employing input via Annotation @CsvSource (e.g.@CsvSource({ "@", "*", "#", "?", "-", "$", "!", "0" }). When running said test, the test ...
3
votes
2
answers
1k
views
How can I write parameterized tests with open source testcafe?
I found a lot of introductions to parameterized tests/ test cases for test cafe, but the syntax is completely different to the one I am using. I guess they're for the discontinued paid version. How ...
0
votes
1
answer
945
views
Parameterize pytest using fixture loaded from database
I'm trying to use pytest to take in an id for a suite to run, load the suite from a db, and then generate the test cases in a parameterized fashion. The code below shows the gist of what I want to do, ...
3
votes
1
answer
5k
views
Using pytest on ranges of many parameters
Let's say I have a Simulation object whose core attribute is a dictionary of parameters that takes something like the following form:
@pytest.fixture
def param_base():
'''Dict of parameter ...