Questions tagged [parameterized-unit-test]
Parameterized unit tests is a feature of some unit testing frameworks. It supports executing a given unit test multiple times with different arguments.
parameterized-unit-test
124
questions
1
vote
2
answers
48
views
How can I write a test with Xunit that accepts an enum as parameter?
I try to write a test that looks like this:
private static readonly IEnumerable<MyEnumType> ListOfEnumValues = Enum.GetValues(typeof(MyEnumType)).Cast<DocumentType>();
private static ...
0
votes
1
answer
45
views
Accessing the `UniqueId` passed to a JUnit5 Session from inside an Extension
Background:
https://github.com/sageserpent-open/americium/issues/69
https://github.com/sageserpent-open/americium/issues/66
These concern an extension that generates test data for a JUnit5 test, ...
0
votes
0
answers
109
views
JUnit5 - can I parameterize execution of entire test class?
Starting from the following generic code, showing a sample test class that needs to be executed for several rounds of input data:
import java.util.stream.Stream;
import org.junit.jupiter.api.*;
import ...
0
votes
0
answers
69
views
Access testData from beforeEach for parameterized test
I do want to create test data in the beforeEach method and access that data to give to the parameterized test but I get an error TS2454: Variable testData is used before being assigned.
describe('...
0
votes
0
answers
158
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 <...
2
votes
0
answers
149
views
JUnit5: Same parameterized test against two different sets (depending on tags)
I have two different sets of parameter sources for a parameterized test (set 1 being a subset of set 2). Depending on JUnit5 tags I want to execute the same test method either against set 1 or set 2.
...
0
votes
0
answers
23
views
Mocha - How to Update parameterized test parameters from before hook [duplicate]
describe('', () => {
let ids = [];
before('',() => {
cypress.api('GET', 'http://localhost:3000/api/id-list').then((response) => {
response.body.foreach((id) => {
...
0
votes
1
answer
83
views
How to pass a function name in parametrize in pytest and How can i use that in testcase?
In the below script i would like to parametrize functions call RegisterClientCabinMovementDetection(x) and RegisterClientOccupantInSeatDetection(x) (made bold in script)so on... is there any way to ...
4
votes
2
answers
4k
views
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....
0
votes
1
answer
57
views
How do I use pytest fixture dependencies and params at the same time?
I'm trying to create a fixture that has dependencies on other fixtures and is also parameterized. Example:
@pytest.fixture(scope="module")
def fix1():
...
@pytest.fixture(scope="...
1
vote
1
answer
928
views
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 ...
0
votes
1
answer
354
views
changing configuration value in spring-boot app with values of parameterized test
I use this in my MyService.kt.
The useXml is read via application.yml and application-test.yml
@Service
class MyService (
@Value("\${something.use-xml}")
var useXml: Boolean = false
)...
1
vote
1
answer
571
views
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&...
0
votes
2
answers
63
views
How to reference an object in a class using a decorator
I have a list of dicts defined in setUpClass in a Django TestCase:
class MyTest(TestCase):
@classmethod
def setUpClass(cls):
myobj = MyModel.objects.create()
cls.MY_LIST = [ ...
-1
votes
1
answer
464
views
Reuse JUnit 5 @ArgumentsSource Parameterized test class across different java projects
I have below maven java projects:
com.validator
com.demoModel1
com.demoModel2
Validator project contains the validation code and the jar is used by demoModel1 and demoModel2 projects to perform ...