4

I have a JUnit test, which uses the Parameterized runner. I have two parameters to be passed (country names) Once this Junit runs in the HTML report for each parameter it gives the result. But it gives the result with testname1[0], testname1[1]..... and so forth for parameter. (for each parameter it will add [] after test name )

I want to customize the result for example 2 parameters are Country names. I would like to have something like CountryName1 - under that testName1. Then CountryName2.. testName.

Is there a way? Thanks in advance.

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
java_enthu
  • 2,279
  • 7
  • 44
  • 74

3 Answers3

2

There is already an issue for JUnit, which proposes to extend the Parameterized runner to support better test names. Unfortunately the issue is not solved yet.

An alternative is to use CallbackParams.

See also

Change test name of parameterized tests?

Community
  • 1
  • 1
Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
1

With version 4.11 of JUnit, it is now possible to rename the parameterized tests. See this answer which tells how to get this done.

Community
  • 1
  • 1
Shiva Kumar
  • 3,111
  • 1
  • 26
  • 34
0

recently i started zohhak project. it lets you write:

@TestWith({
   "25 USD, 7",
   "38 GBP, 2",
   "null,   0"
})
public void testMethod(Money money, int anotherParameter) {
   ...
}

and each invocation is reported with parameters - check screenshot on main page

piotrek
  • 13,982
  • 13
  • 79
  • 165