Print
IgnoreExample

Sometimes it doesn't make sense to run a test, when for example external resources are not available, sometimes you might decide to disable a test for a while because you've decided that a bug is non-critical. PicoUnit provides a capability to disable tests without commenting them out.

package example.ignored;

import example.model.Database;

import picounit.Ignore;
import picounit.IgnoreReason;
import picounit.Test;

public class PersonMapperTest implements Test, Ignore {
  private final Database database;

  public PersonMapperTest(Database database) {
    this.database = database;
  }

  public void ignoredWhen(IgnoreReason ignoreReason) {
    ignoreReason.setCondition(!database.isConnected());
    ignoreReason.setWhy("Database not running");
  }

  public void testThatWontRun() {
  }
}

Here's is what the above test would look like when run in an IDE:

Powered by Atlassian Confluence