JUnit's @Parameterized runner provides support for parameterized tests.
Questions tagged [parameterized]
525 questions
225
votes
15 answers
Changing names of parameterized tests
Is there a way to set my own custom test case names when using parameterized tests in JUnit4?
I'd like to change the default — [Test class].runTest[n] — to something meaningful.

Epaga
- 38,231
- 58
- 157
- 245
71
votes
9 answers
Excluding a non param test in parameterized test class
Is there any annotation in JUnit to exclude a non param test in parameterized test class?

user405516
- 743
- 1
- 5
- 7
68
votes
8 answers
Create multiple parameter sets in one parameterized class (junit)
Currently I have to create a parameterized test class for every method that I want to test with several different inputs. Is there a way to add this together in one file?
Right now there's CalculatorTestAdd.java which has a set of parameters that…

Jeroen Vannevel
- 43,651
- 22
- 107
- 170
62
votes
5 answers
Difference between JUnit Theories and Parameterized Tests
What is the difference between a Theory and a Parameterized test?
I'm not interested in implementation differences when creating the test classes, just when you would choose one over the other.

dogbane
- 266,786
- 75
- 396
- 414
58
votes
4 answers
When using JUnit's @Parameterized, can I have some tests still run only once
I use @Parameterized in many cases to run tests on a number of permutations. This works very well and keeps the test-code itself simple and clean.
However sometimes I would like to have some of the test-methods still run only once as they do not…

centic
- 15,565
- 9
- 68
- 125
56
votes
3 answers
Parameterized Queries with LIKE and IN conditions
Parameterized Queries in .Net always look like this in the examples:
SqlCommand comm = new SqlCommand(@"
SELECT *
FROM Products
WHERE Category_ID = @categoryid
",
conn);
comm.Parameters.Add("@categoryid",…

Tom Ritter
- 99,986
- 30
- 138
- 174
51
votes
4 answers
Junit Parameterized tests together with Powermock - how?
I've been trying to figure out how to run parameterized tests in Junit4 together with PowerMock. The problem is that to use PowerMock you need to decorate your test class with
@RunWith(PowerMockRunner.class)
and to use parameterized tests you have…

Anders Hansson
- 3,746
- 3
- 28
- 27
36
votes
2 answers
Override a pytest parameterized functions name
My parameters determine the name of my parameterized pytest. I will be using a some randomized params for these tests. In order for my reporting names in junit to not get messed up, I'd like to create a static name for each parameterized test.
Is it…

SomeGuyOnAComputer
- 5,414
- 6
- 40
- 72
28
votes
3 answers
Retrieve build number or artifacts of downstream build in Jenkins
I have a job (call it BIGJOB) in Jenkins; several of the build steps are to trigger builds on other jobs (call them SMALLJOB) using the Parameterized Trigger Plugin then wait for them to complete. What I need to do is retrieve artifacts from the…

Jason Swager
- 6,421
- 6
- 41
- 56
28
votes
2 answers
How to pass build artifact into another job in Jenkins
Setup
I have two jobs in Jenkins:
build master - this builds the code and creates an artifact
deploy master - this deploys the artifact
Currently, deploy master has "Copy artifacts from another project" build step using "latest successful…

styfle
- 22,361
- 27
- 86
- 128
26
votes
1 answer
AndroidJUnit4 and Parameterized tests
Google provide new classes to write tests for Android, and especially using jUnit 4: https://developer.android.com/tools/testing-support-library/index.html
I was wondering if it is possible to use the AndroidJUnit4 runner, as well as the…

Gaëtan
- 11,912
- 7
- 35
- 45
26
votes
6 answers
Java map, key = class, value = instance of that class
I'm not sure what I want to do is possible, but if it is, I want to find out how. Basically, I want to create a Map where the key is a class (java.lang.Class), and value for that entry is an instance of that class. Currently I have
private…

dnc253
- 39,967
- 41
- 141
- 157
24
votes
3 answers
Java Generic Interface vs Generic Methods, and when to use one
I was wondering, aside from syntactic difference, when would one use a generic interface over a method that accepts a generic parameter?
public interface Flight{
void fly(T obj);
}
over
public interface Flight{
void fly(T obj);
}

yev
- 512
- 4
- 14
23
votes
7 answers
How do I test exceptions in a parameterized test?
In JUnit4 you can write parameterized unit tests by providing parameters collection in one method, which will be passed to the constructor of the test and testing in another method. If I have a parameter for which I expect an exception to be thrown,…

Gabriel Ščerbák
- 18,240
- 8
- 37
- 52
21
votes
12 answers
How should I pass a table name into a stored proc?
I just ran into a strange thing...there is some code on our site that is taking a giant SQL statement, modifying it in code by doing some search and replace based on some user values, and then passing it on to SQL Server as a query.
I was thinking…

Beska
- 12,445
- 14
- 77
- 112