Question: I am trying to create a reusable template class for my unit test cases. Suppose classes Sample, and SampleTest belong to the same package, while Template belongs to a different package. I get error instantiating Sample class. I expect the method will be executed as if it were a method of the SampleTest class that have access to Sample. Are there ways to make this work?

```
public SampleTest extends Template<Sample> {
     public void testMethod() {
          getTarget().method();
     }
}

public class Template<T> extends TestCase {

    /** Spied, object instance to test. */
    private transient T targetObject;

    /** Test class type to be derived as parameter type of test subclass. */
    private transient final Class<T> targetType;

    @Override
    public void setUp() throws Exception
    {
        super.setUp();
        setupTargetObject();
    }

    protected void setupTargetObject()
    {
        final T realObject =  targetType.newInstance(); //ERROR here if class under test is non-public
        targetObject = Mockito.spy(realObject);
    }

    protected Template() {
            final ParameterizedType paramedType = (ParameterizedType) getClass().getGenericSuperclass();
            targetType = (Class<T>) paramedType.getActualTypeArguments()[0];
    }

    protected T getTarget()
    {
        return targetObject;
    }

}

```

Answer: 
You can use [CSS Pseudo classes](http://css-tricks.com/pseudo-class-selectors/) to do this, therefore you won't need an "arrow" element:

```css
div.error-label {
  padding: 10px;
  color: #fff;
  background-color: #DA362A;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  width: 190px;
  margin: 30px;
}

div.error-label:before {
  content: ' ';
  height: 0;
  position: absolute;
  width: 0;
  left: 18px;
  border: 10px solid transparent;
  border-right-color: #DA362A;
}
```

```html
<div class="error-label">This field is required.</div>
```
Here is the solution

```css
div.error-label{
    padding: 7px 10px 0 4px;
    color: #fff;
    background-color: #DA362A;
    -webkit-border-radius: 5px; 
    -moz-border-radius: 5px; 
    border-radius: 5px;
    width: 150px;
    margin-left: 5px;
}

div.error-label-arrow{
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent; 
    border-right:10px solid #DA362A;
    float: left;
    height: 1px;
    margin-top: 3px;
}
```

```html
<div class="error-label-arrow"></div>
<div class="error-label">This field is required.</div>
```