View Javadoc
1   package org.junit.tests.description;
2   
3   import org.junit.Test;
4   import org.junit.runner.Description;
5   import org.junit.runner.RunWith;
6   import org.junit.runners.Parameterized;
7   
8   import java.util.Arrays;
9   import java.util.Collection;
10  
11  import static org.junit.Assert.assertEquals;
12  import static org.junit.Assert.assertNotNull;
13  
14  /**
15   * @author Dmitry Baev [email protected]
16   *         Date: 03.05.14
17   */
18  @RunWith(Parameterized.class)
19  public class TestDescriptionMethodNameTest {
20  
21      private String methodName;
22  
23      public TestDescriptionMethodNameTest(String methodName) {
24          this.methodName = methodName;
25      }
26  
27      @Parameterized.Parameters
28      public static Collection<Object[]> getMethodNames() {
29          return Arrays.asList(
30                  new Object[]{"simple"},
31                  new Object[]{"with space"},
32                  new Object[]{"[]!@#$%^&*()"},
33                  new Object[]{""},
34                  new Object[]{"\t"},
35                  new Object[]{"\n"},
36                  new Object[]{"\r\n"},
37                  new Object[]{"\r"},
38                  new Object[]{"\u0085"},
39                  new Object[]{"\u2028"},
40                  new Object[]{"\u2029"}
41          );
42      }
43  
44      @Test
45      public void methodNameTest() throws Exception {
46          Description description = Description.createTestDescription("some-class-name", methodName);
47          assertNotNull("Method name should be not null", description.getMethodName());
48          assertEquals(methodName, description.getMethodName());
49      }
50  }