草庐IT

rule_student_age

全部标签

【单元测试】Junit 4(八)--junit4 内置Rule

1.0Rules​ Rules允许非常灵活地添加或重新定义一个测试类中每个测试方法的行为。测试人员可以重复使用或扩展下面提供的Rules之一,或编写自己的Rules。1.1TestName​ TestNameRule使当前的测试名称在测试方法中可用。用于在测试执行过程中获取测试方法名称。在starting()中记录测试方法名,在getMethodName()中返回例如:importstaticorg.junit.Assert.*;importorg.junit.Rule;importorg.junit.Test;importorg.junit.rules.TestName;publicclas