Working with code R013

If you receive the output message R013, this means that Cover CLI 3.0 cannot write tests for a method because it is unable to find ‘useful’ inputs to provide to the method. Please consider the parameters of the method under test, along with the class variables and instance variables it uses to ensure that it is possible to set reasonable values for these quantities.

Here are a few simple scenarios where this is not possible and which could lead to an R013 output message. Check whether any problems similar to the following could be occurring in the method under test:

Inaccessible constructor for class required as argument

public class PassAsArgument() {
  private PassAsArgument() {}
}

public class SomeClass() {
  public static Object acceptArgument(PassAsArgument passAsArgument) {
    // Do processing
  }
}

There are three solutions to the scenario above: make the PassAsArgument constructor public, provide a static factory method which returns an instance of PassAsArgument, or provide a publicly accessible default instance.

The method uses a private member with an unset or bad value

public class SomeClass() {
  private Runnable value;
  // ...
  public int runSomething() {
    // ...
    value.run();
    // ...
  }
}

Again, there are three solutions to this scenario. Ensure that value is initialised with a proper value, make value public or provide a getter and a setter for value.

results matching ""

    No results matching ""