Using External IDs

You can use External IDs to uniquely identify test nodes and suite nodes in test packages. An External ID is provided as a property for each test node and each suite node. The automatically generated External ID identifies a unique test method by the fully qualified name of the class and the method with an "~" prepended.

For JUnit tests, the following schema is used for the automatically generated External ID: ~<package name>.<class name>#<method name>.

When refactoring JUnit test classes, the automatic generation of the External ID is not applicable, because the result information of tests previous to the refactoring will be lost when creating a new test. In this case the External ID for the test must be manually defined. The refactored method is re-identifiable, because the External ID remains unchanged while moving a JUnit test or changing its name. The External ID can be manually set in the source code as an annotation.

The following code example shows such an annotation for JUnit tests:

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public @interface ExternalId {
  String externalId();

The annotation can be used in a JUnit test to annotate classes and test methods as shown:

import static org.junit.Assert.*;        
import org.junit.Test;

import com.borland.runner.ExternalId;

public class JUnit4test {
  public void test1() {
  public void test2() {

Be aware that using External IDs with JUnit runner 'org.junit.runners.Parameterized' is not supported for test methods, because the External ID is not unique for repeated runs of a method with different parameters. As a work around an External ID could be specified on class level, but must be omitted on method level. An example follows:

public class TestCaseParameterizedWithExternalId {

  public static Collection<Object[]> parameterFeeder() {
    return Arrays.asList(new Object[][] {
        { "param_name1", "param_value1" }, // set of parameters per run, type matching constructor must exist!
        { "param_name3", "param_value3" },
        { "param_name2", "param_value2" },

  private String paramName;
  private String paramValue;
  public TestCaseParameterizedWithExternalId(String paramName, String paramValue) {
    this.paramName = paramName;
    this.paramValue = paramValue;
  public void testWithParams() {
    System.out.println(String.format("run with parameter: name='%s', value='%s'", paramName, paramValue));
Note: The setting of the External ID for a JUnit test is only possible for tests using JUnit 4.4 or higher.