Questions tagged [junitparams]

JUnitParams project adds a new runner to JUnit and provides much easier and readable parametrised tests for JUnit >=4.6.

Main differences to standard JUnit Parametrised runner:

more explicit - params are in test method params, not class fields less code - you don't need a constructor to set up parameters you can mix parametrised with non-parametrised methods in one class params can be passed as a CSV string or from a parameters provider class parameters provider class can have as many parameters providing methods as you want, so that you can group different cases you can have a test method that provides parameters (no external classes or statics anymore) you can see actual parameter values in your IDE (in JUnit's Parametrised it's only consecutive numbers of parameters):

31 questions
12
votes
6 answers

junitparameter exception method should have no parameter

By using JUnitParameter for testing a methode I have an exception. My code is similar to lot of example on JUnitParameter: private Object parametersForTestSetDistanceFormated() { return new Object[][]{ {100, "_1,__ km"}, …
Patrick Lec
  • 173
  • 1
  • 1
  • 11
9
votes
2 answers

JUnitParams with Mockito

This could be a XY problem but I want to ask: I am using JUnitParams to be able to run my test method 10 times with different objects. The problem is that the injections don't work (@Mock and @InjectMocks). I can use PersonService personService =…
Jack Flamp
  • 1,223
  • 1
  • 16
  • 32
8
votes
3 answers

Using "Comma" or "pipe" within JunitParams

I'm trying to use JunitParams in order to parametrized my tests. But my main problem is that the parameters are strings with special characters, tilde or pipe. import org.junit.Rule; import org.junit.Test; import…
GaspardP
  • 880
  • 1
  • 12
  • 24
6
votes
2 answers

JUnitParams not working with String array

Consider this test class, working with JUnit 4 and JUnitParams: import static junitparams.JUnitParamsRunner.$; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import…
Juergen
  • 3,489
  • 6
  • 35
  • 59
5
votes
2 answers

How to give null value to a parameter when using @FileParameters of JUnitParams

I try to use FileParameters annotation of JUnitParamsRunner. I cannot give null to a variable. The code and test file is below. @RunWith(JUnitParamsRunner.class) public class PasswordCheckerFileParameterizedTest { @Test …
Erkan Erol
  • 1,334
  • 2
  • 15
  • 32
4
votes
2 answers

How to apply two @RunWith in spring boot starter test

I am using spring boot starter test for writing JUnit test cases. I would love to use JunitParamrunner which facilitates passing files for parameterized test.Basically it reads data from file line by line and for every line invoke a test case. The…
rohit
  • 862
  • 12
  • 26
4
votes
3 answers

Junit parameterized tests using file input

I have a query about using parameterized tests for my unit testing of my APIs. Now instead of building an arraylist like Arrays.asList(new Object[]{ {1},{2},{3} }); I want to read lines in the file one by one split them space and fill them in…
Sourabh
  • 1,253
  • 6
  • 21
  • 39
3
votes
1 answer

Eclipse/JUnit "Test class not found" when subclassing BlockJUnit4ClassRunner

I am trying to subclass BlockJUnit4ClassRunner, in order to be able to use this nice parameterizing framework: JUnitParams. I can't use the built-in JUnit parameterizing runner, since I need to do some additional work in the runner. Anyway, eclipse…
3
votes
2 answers

JUnitParams for each method of class

Is it possible to run parameterized test for each method of test class with JUnitParams and class level annotations? Something like: @RunWith(JUnitParamsRunner.class) @Parameters(method = "paramsGenerator") public class TestMethod { public…
Feedforward
  • 4,521
  • 4
  • 22
  • 34
3
votes
1 answer

Parametrized android tests with different sets of data

Currently i'm researching a ways of writing unit and integration tests for android apps. I have so confused that there is absent a possibility to provide a set of parameters directly to the method like JUnitParams library does. So i have several…
Beloo
  • 9,723
  • 7
  • 40
  • 71
3
votes
0 answers

maven -Dsurefire.rerunFailingTestsCount with parameterized tests

I want to re-run failed tests with maven. I'm using surefire.rerunFailingTestsCount for this: mvn '-Dtest=LoginTest#loginAsValidUser' '-Dsurefire.rerunFailingTestsCount=1'clean test However, after tests fail, they are not found again by junit when…
bukva-ziu
  • 126
  • 8
3
votes
2 answers

Create test case name (using JUnitParams) from an array passed as a parameter

Is there a way to print contents of an array (passed as one of test parameters) using the @TestCaseName annotation? What I mean is that I want this test case private static final File JAVA_DIRECTORY = get("src/main/java/").toFile(); private static…
Maciej
  • 546
  • 4
  • 15
1
vote
1 answer

junitparameter exception object of class

I have a junit test. I'm using JUnitParamsRunner in spring 4.1 and I can't resolve the problem. I want to run the test with the object and make more like this test. but in every run I getting the same error. when I looked for other result in…
nadav3200
  • 11
  • 1
  • 5
1
vote
1 answer

How to identify different test cases when parameterizing

When using JUnitParams, I can pass an array of Objects where each element will be used to run a test. Is there any way to add a name or identification to each of these? So when I run these JUnit test, Eclipse would show the name of each case instead…
Eduardo Coria
  • 71
  • 1
  • 2
1
vote
1 answer

JMockit and parameterized tests (JUnit parameterized or JUnitParams)

I was wondering if JMockit is compatible with JUnit parameterized tests or JUnitParams, because I haven't found a way to make them work together so far, since you can only specify one JUnit runner, and both JMockit, JUnitParams and Parameterized…
sudokai
  • 507
  • 2
  • 8
  • 15
1
2 3