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
1
vote
1 answer

JunitParams 1.0.6 initializationError

I have tests which have been running fine with JunitParams 1.0.5, after I upgraded to JunitParams 1.0.6, then got initializationError. Can anyone help with this? Selenium: 3.3.1 JunitParams: 1.0.6 Firefox: 52ESR Stack…
Jingjing
  • 13
  • 1
  • 5
1
vote
2 answers

Why are field variables null after setting them in JUnitParams method?

I am writing a test class using JUnitParams and Mockito. I want to use a Mockito mock as parameter. In my test I have about ten mocks and I want to pass only one mock to define a special behaviour for it. I reproduced the problem in a simple…
adebasi
  • 3,535
  • 2
  • 19
  • 33
1
vote
1 answer

how to get flexible columns with junitparams

I have this situation where I'm reading values from input file using junitparams. In some cases, my rows have values in all the columns (say 5), however, in other cases only the first few columns have values. I want junitparams to assign value for…
Hemant
  • 1,313
  • 17
  • 30
1
vote
1 answer

Parametrized JUnit+JUnitParams test is not working for arrays with

Can you tell me why the test is not working? I got : java.lang.IllegalStateException: While trying to create object of class class [Ljava.lang.Integer; could not find constructor with arguments matching (type-wise) the ones given in…
Sergio
  • 3,317
  • 5
  • 32
  • 51
1
vote
1 answer

JUnitParams passing non-primitive objects to test method

JUnitParams is only passing primitive objects (String, int) but not other objects, eg.: @Test @Parameters testMethod(String sample, MyObj myobj, MyObj myobj) {} private Object[] parametersForTestMethod() { return $($("testString", myobj,…
user1810502
  • 531
  • 2
  • 7
  • 19
0
votes
0 answers

Junit: @Parameters method is ran before any other test

I have a regular parametrized test class, done with JUnit 4.12 (also tested 4.13.1). @RunWith(Parameterized.class) public class MyTest { @Test public void myTest() ... @Parameters public static Collection data() { ...} public…
Rolintocour
  • 2,934
  • 4
  • 32
  • 63
0
votes
0 answers

JunitParams and PowerMockRunner null pointer exception

I can't figure out where the error is in my tests. I am using PowerMockRunner to simulate some static methods and JunitParams to add parameters to the test cases. When I run the tests, I get the following error: java.lang.NullPointerException at…
Novice
  • 423
  • 1
  • 9
  • 17
0
votes
1 answer

Usage of @TestCaseName with @FileParameters in JUnitParams

I use JUnit4 with JUnitParams for testing and I want to know more about the usage of the @TestCaseName annotation. I understand the usage of @TestCaseName with the @Parameters annotation, but I want to know about how to use @TestCaseName with the…
0
votes
0 answers

'No tests found with testrunner JUnit4' when using JUnitParams

I have a test class which uses JUnitParams and when I try to run it, I get the error in the title. The JUnitParams library is correctly installed, and I don't have any compiler errors. I am using JUnit 4.13 and JUnitParams 1.1.1 . I am running the…
biatheawesome
  • 31
  • 1
  • 4
0
votes
1 answer

JUnitParamsRunner with Guice

I have a java test which is based on guice. I want to pass multiple parameter sets which are supported by JUnitParams. But it looks like I can pass only one @RunWith. So essentially I can add either JUnitParamsRunner or GuiceTestRunner. What is the…
Oliver Blue
  • 677
  • 2
  • 9
  • 22
0
votes
1 answer

TypeNotPresentException with JUnitParamsRunner

My Java-Code looks like this: Person.java public class Person { private int age; public Person(int age) { this.age = age; } public boolean isAdult() { return age >= 18; } @Override public String toString() { return "Person of age: " +…
uberroot4
  • 53
  • 2
  • 12
0
votes
1 answer

How to use @Parameters in @BeforeClass for Junit

I want to use Parameters in BeforeClass to login as a different user with different role. I use: JUnitParams 1.0.2 junit 4.12 Selenium wedbriver 2.53.1 Here is my code FirefoxLogin.java public class FirefoxLogin { public static WebDriver…
mszafranek
  • 11
  • 3
0
votes
2 answers

How to use Mockito stubs in a JUnitParams parameter provider?

I am trying to learn JUnit. Working on a particular problem I decided to use JUnitParams parameter providers. Each set of parameters for a test method I'm writing should contain two input values and a list against which results of a method call…
Limbo Exile
  • 1,321
  • 2
  • 21
  • 41
0
votes
2 answers

JUnitParams - executing separate methods before test

@RunWith(JUnitParamsRunner.class) public class MySimpleTest { private MyRec rec; private Matrix matrix; @Before public void createRecognizerBeforeEveryExecution() { rec = new MyRec(); matrix =…
0
votes
1 answer

Parameterization in Junit

I am learning JUnit and I am getting the following error for the following point in the code: The attribute method is undefined for the annotation type Parameterized.Parameters The method is: @Test @Parameters(method = "getMoney") private…