junitparams.naming
Annotation Type TestCaseName
@Retention(value=RUNTIME)
public @interface TestCaseName
Use this annotation to specify the name for individual test case.
|
Optional Element Summary |
String |
value
A template of the individual test case name. |
value
public abstract String value
- A template of the individual test case name.
This template can contain macros, which will be substituted by their actual values at runtime.
Supported macros are:
- {index} - index of parameters set (starts from zero). Hint: use it to avoid names duplication.
- {params} - parameters set joined by comma.
- {method} - testing method name.
-
{0}, {1}, {2} - single parameter by index in current parameters set.
If there is no parameter with such index, it will use empty string.
Lets assume, that we are testing Fibonacci sequence generator. We have a test with the following signature
@Parameters({ "0,1", "8,34" })
public void testFibonacci(int indexInSequence, int expectedNumber) { ... }
Here are some examples, that can be used as a test name template:
- {method}({params}) => testFibonacci(0, 1), testFibonacci(8, 34)
- fibonacci({0}) = {1} => fibonacci(0) = 1, fibonacci(8) = 34
- {0} element should be {1} => 0 element should be 1, 8 element should be 34
- Fibonacci sequence test #{index} => Fibonacci sequence test #0, Fibonacci sequence test #1
- Default:
- "{method}({params}) [{index}]"
Copyright © 2017 Pragmatists. All rights reserved.