Skip to content

Instantly share code, notes, and snippets.

@vorburger
Created July 27, 2016 18:06
Show Gist options
  • Select an option

  • Save vorburger/799bb7d0ed22d179b6348e7cd4b12df5 to your computer and use it in GitHub Desktop.

Select an option

Save vorburger/799bb7d0ed22d179b6348e7cd4b12df5 to your computer and use it in GitHub Desktop.
/*
* Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.netvirt.aclservice.tests.utils.inject;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.InitializationError;
/**
* JUnit Runner which creates test instances from a {@link Provider} given in an
* {@link InstanceProvidedBy} annotation, instead of by 'new' (Test's default
* constructor) as core JUnit does.
*
* @author Michael Vorburger
*/
public class ProviderRunner extends BlockJUnit4ClassRunner {
public ProviderRunner(Class<?> klass) throws InitializationError {
super(klass);
}
@Override
protected Object createTest() throws Exception {
return new InstanceProvidedByUtil().getInstance(getTestClass().getJavaClass());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment