Usage of the UUT Annotation

The Uut annotation allows you to specify who the unit under test is.

Field Level

If you are using a field in you test case class, that is initialized in a setup method, the following annotation will mark the UUT.

public class DummyProductionClassTest {
  @Uut
  private DummyProductionClass uut;
  ...
}

The tool will determine the type of the UUT by the type of the annotated field.

Type Level explicitly Naming the Type

If you do not explicitly instantiate the UUT or you set it up in the test method, use the annotation with its type parameter to explicitly specify the type of the UUT like this:

@Uut(type = DummyProductionClass.class)
public class DummyProductionClassTest {
  ...
}

Type and Method Level

The example above assumes that the UUT of each test method in this test case class is the same. If this is not the case, please specify the UUT at method level. You may even combine the two methods in which case the UUT is determined by the type level annotation if no method level annotation is given.

@Uut(type = DummyProductionClass.class)
public class DummyProductionClassTest {

  @Test
  @Uut(type = DummyProductionInnerClass.class)
  public void xxx() {
    ...
  }

  @Test
  public void yyy() {
    ...
  }

  @Test
  public void zzz() {
    ...
  }
  ...
}

Specifying the Method Name

You may optionally point to the method of the UUT being tested by specifying the method property. Using the testdoc-plugin for Eclipse this allows to navigate from the test story in the view to the method that is tested.

@Test
@Uut(type = MyProductionClass.class, method = "myMethod()")
public void myTestCaseMethod() {
  ...
}

Specify the types as in the parameter list of the method exactly as given in the method declaration of the production code you want to reference. Typically this is only the simple type name.

@Test
@Uut(type = MyProductionClass.class, method = "myMethod(String,int,List)")
public void myTestCaseMethod() {
  ...
}

If a class tests all overloaded methods, simply specify the name of this method without parameter list (no parentheses).

@Test
@Uut(type = MyProductionClass.class, method = "myOverloadedMethod")
public void myTestCaseMethod() {
  ...
}