Questions tagged [parameterized]

JUnit's @Parameterized runner provides support for parameterized tests.

JavaDoc of @Parameterized runner

501 questions
212
votes
13 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
  • 35,261
  • 53
  • 143
  • 239
125
votes
19 answers

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

I tried run Parameterized Unit Test as below in Android Studio. import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; import org.junit.Test; import org.junit.runner.RunWith; import…
Elye
  • 30,821
  • 26
  • 115
  • 272
62
votes
10 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
  • 653
  • 1
  • 5
  • 7
61
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
  • 242,394
  • 72
  • 372
  • 395
57
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
  • 41,258
  • 21
  • 92
  • 157
52
votes
4 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
  • 94,954
  • 29
  • 130
  • 168
49
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
  • 14,264
  • 6
  • 58
  • 113
46
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,658
  • 3
  • 26
  • 27
27
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,251
  • 6
  • 38
  • 55
27
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
  • 16,664
  • 22
  • 73
  • 115
25
votes
5 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
  • 38,347
  • 36
  • 135
  • 148
22
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
  • 9,942
  • 4
  • 28
  • 44
21
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
  • 16,864
  • 8
  • 33
  • 50
17
votes
4 answers

Returning an objects subclass with generics

With an abstract class I want to define a method that returns "this" for the subclasses: public abstract class Foo { ... public T eat(String eatCake) { ... return this; } } public class CakeEater…
Sarabjot
  • 449
  • 1
  • 4
  • 13
17
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
  • 342
  • 3
  • 14
1
2 3
33 34