@Parameters:用于JUnit的参数化功能,用来标记准备数据的方法。java
注意:该方法须要知足必定的要求: 函数
(1)该方法必须为public static的测试
(2)该方法返回值必须为java.util.Collection类型 this
(3)该方法的名字不作要求 spa
(4)该方法没有参数code
@RunWith(Parameterized.class ) public class TestDemoParamter { private String target; private String except; @Parameters public static Collection setParam() { return Arrays.asList(new Object[][] { { "emplee_info", "empleeInfo" }, // 测试正常状况 { null, null }, // 测试null时处理状况 { "", "" }, // 测试空字符串的状况 { "employee_info", "EmployeeInfo" }, // 测试当首字母大写时的状况 { "employee_info_a", "employeeInfoA" }, // 测试当尾字母为大写时的状况 { "employee_a_info", "employeeAInfo" } // 测试多个相连字母大写时的状况 }); } /** * 参数化测试必须的构造函数 * * @param expected 指望的测试结果 ,对应参数集中的第一个参数 * @param target 测试数据,对应结果集中的第二个参数 */ public TestDemoParamter(String target, String except) { this.except = except; this.target = target; } @Test public void testParam(){ Assert.assertEquals(except, target); } }