001/* 002 * (C) Copyright 2012-2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 */ 017package org.nuxeo.runtime.test.runner; 018 019import java.util.List; 020 021import org.junit.runners.model.FrameworkMethod; 022import org.junit.runners.model.InitializationError; 023 024import com.tngtech.java.junit.dataprovider.DataProviderRunner; 025 026/** 027 * Features runner which integrates with jgiven data provider. 028 * 029 * @see DataProviderRunner 030 * @since 8.4 031 */ 032public class FeaturesRunnerWithParms extends FeaturesRunner { 033 034 public FeaturesRunnerWithParms(Class<?> classToRun) throws InitializationError { 035 super(classToRun); 036 } 037 038 class Provider extends DataProviderRunner { 039 040 public Provider() throws InitializationError { 041 super(getTargetTestClass()); 042 } 043 044 @Override 045 protected List<FrameworkMethod> computeTestMethods() { 046 return super.computeTestMethods(); 047 } 048 049 @Override 050 protected void validateTestMethods(List<Throwable> errors) { 051 super.validateTestMethods(errors); 052 } 053 } 054 055 Provider provider; 056 057 Provider provider() { 058 if (provider == null) { 059 try { 060 provider = new Provider(); 061 } catch (InitializationError cause) { 062 throw new AssertionError("Cannot initialize data provider", cause); 063 } 064 } 065 return provider; 066 } 067 068 @Override 069 protected List<FrameworkMethod> computeTestMethods() { 070 return provider().computeTestMethods(); 071 } 072 073 @Override 074 protected void validateTestMethods(List<Throwable> errors) { 075 provider().validateTestMethods(errors); 076 } 077 078}