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>
```
> 
> You can achieve this by using `Pseudo elements` check below answer
> 
> 
> 

```css
.error{
   position: relative;
   background: red;
   padding: 10px;
   color: #fff;
   margin:0 0 0 12px;
   width:auto;
   display:inline-block;

 }

.error::before {
 content: "";
 width: 0;
 height: 0;
 border-style: solid;
 border-width: 9px 11px 9px 0;
 border-color: transparent red transparent transparent;
 position: absolute;
 left: -11px;
 top: 0;
 bottom: 0;
 margin: auto;
}

.arrow_type2 {
 position: relative;
 background: #28d57f;
 border: 3px solid #0cf5a7;
  padding:50px 20px;
  margin-left:20px;
  margin-top:20px;
  width:auto;
  display:inline-block;
}
.arrow_type2:after, .arrow_type2:before {
 right: 100%;
 top: 50%;
 border: solid transparent;
 content: " ";
 height: 0;
 width: 0;
 position: absolute;
 pointer-events: none;
}

.arrow_type2:after {
 border-color: rgba(40, 213, 127, 0);
 border-right-color: #28d57f;
 border-width: 10px;
 margin-top: -10px;
}
.arrow_type2:before {
 border-color: rgba(12, 245, 167, 0);
 border-right-color: #0cf5a7;
 border-width: 14px;
 margin-top: -14px;
}
```

```html
<div class="error">This is field required</div>

<div class="arrow_type2">Arrow type two</div>
```