1 package com.atlassian.webdriver.testing.runner;
2
3 import com.atlassian.pageobjects.TestedProduct;
4 import com.atlassian.pageobjects.inject.InjectionContext;
5 import com.atlassian.pageobjects.util.InjectingTestedProducts;
6 import org.junit.runners.model.InitializationError;
7
8 /**
9 * <p/>
10 * Given a tested product supporting injection, injects framework members into the test class and object
11 * before running the test.
12 *
13 * <p/>
14 * The underlying product, or its binder, MUST implement the {@link com.atlassian.pageobjects.inject.InjectionContext}
15 * for this to work.
16 *
17 * @since 2.1
18 */
19 public abstract class AbstractProductContextRunner extends AbstractInjectingRunner
20 {
21 /**
22 * Constructor compatible with the underlying default JUnit4 runner.
23 *
24 * @throws org.junit.runners.model.InitializationError
25 * if the test class is malformed.
26 */
27 public AbstractProductContextRunner(Class<?> klass) throws InitializationError
28 {
29 super(klass);
30 }
31
32 @Override
33 protected final InjectionContext getInjectionContext()
34 {
35 return InjectingTestedProducts.asInjectionContext(getProduct());
36 }
37
38 /**
39 * The product must support injection, such that
40 * {@link com.atlassian.pageobjects.util.InjectingTestedProducts#supportsInjection(com.atlassian.pageobjects.TestedProduct)}
41 * returns <code>true</code>. Otherwise this runner will fail at runtime when trying to
42 * perform injection.
43 *
44 * @return product instance
45 */
46 protected abstract TestedProduct<?> getProduct();
47 }