Allow for empty rule chains.
@@ -33,11 +33,12 @@ public class RuleChainFactory {
* @return a new rule chain.
*/
public static RuleChain create(final TestRule... testRules) {
- RuleChain ruleChain = RuleChain.outerRule(testRules[0]);
- for (int idx = 1; idx < testRules.length; idx++) {
- if (ruleChain != null) {
- ruleChain = ruleChain.around(testRules[idx]);
+ if (testRules == null || testRules.length == 0) {
+ return RuleChain.emptyRuleChain();
}
+ RuleChain ruleChain = RuleChain.outerRule(testRules[0]);
+ for (int i = 1; i < testRules.length; i++) {
+ ruleChain = ruleChain.around(testRules[i]);
}
return ruleChain;
}
