• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package junitparams.naming;
2 
3 import java.lang.annotation.Retention;
4 import java.lang.annotation.RetentionPolicy;
5 
6 /**
7  * Use this annotation to specify the name for individual test case.
8  */
9 @Retention(RetentionPolicy.RUNTIME)
10 public @interface TestCaseName {
11 
12     /**
13      * A template of the individual test case name.
14      * This template can contain macros, which will be substituted by their actual values at runtime.
15      * <p>
16      * Supported macros are:
17      * <ul>
18      * <li><b>{index}</b> - index of parameters set (starts from zero). Hint: use it to avoid names duplication.</li>
19      * <li><b>{params}</b> - parameters set joined by comma.</li>
20      * <li><b>{method}</b> - testing method name.</li>
21      * <li>
22      *     <b>{0}</b>, <b>{1}</b>, <b>{2}</b> - single parameter by index in current parameters set.
23      *     If there is no parameter with such index, it will use empty string.
24      * </li>
25      * </ul>
26      * Lets assume, that we are testing Fibonacci sequence generator. We have a test with the following signature
27      * <pre><code>
28      * {@literal @}Parameters({ "0,1", "8,34" })
29      * public void testFibonacci(int indexInSequence, int expectedNumber) { ... }
30      * </code></pre>
31      * Here are some examples, that can be used as a test name template:
32      * <ul>
33      * <li>{method}({params}) => testFibonacci(0, 1), testFibonacci(8, 34)</li>
34      * <li>fibonacci({0}) = {1} => fibonacci(0) = 1, fibonacci(8) = 34</li>
35      * <li>{0} element should be {1} => 0 element should be 1, 8 element should be 34</li>
36      * <li>Fibonacci sequence test #{index} => Fibonacci sequence test #0, Fibonacci sequence test #1</li>
37      * </ul>
38      */
value()39     String value() default MacroSubstitutionNamingStrategy.DEFAULT_TEMPLATE;
40 }