junitparams.naming.TestCaseName Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JUnitParams Show documentation
Show all versions of JUnitParams Show documentation
Better parameterised tests for JUnit
package junitparams.naming;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Use this annotation to specify the name for individual test case.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface TestCaseName {
/**
* 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
*
* {@literal @}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
*
*/
String value() default MacroSubstitutionNamingStrategy.DEFAULT_TEMPLATE;
}