Package randoop.test

Class ErrorRevealingChecks

java.lang.Object
randoop.test.ErrorRevealingChecks
All Implemented Interfaces:
TestChecks<ErrorRevealingChecks>

public class ErrorRevealingChecks extends Object implements TestChecks<ErrorRevealingChecks>
ErrorRevealingChecks represent failing checks for a particular test sequence. Each check may refer to different variables defined in the sequence, so can only be assumed to be valid at the end of the sequence. Note that there are no expected exceptions in error-revealing tests, and so there should be no ExceptionCheck objects.
  • Field Details

    • EMPTY

      public static final ErrorRevealingChecks EMPTY
      An empty, immutable set of error-revealing checks.
    • checks

      private Set<Check> checks
  • Constructor Details

    • ErrorRevealingChecks

      public ErrorRevealingChecks()
      Create an empty set of error checks.
    • ErrorRevealingChecks

      public ErrorRevealingChecks(Check check)
      Create a singleton set of error checks.
      Parameters:
      check - the check to put in the newly-created singleton set
  • Method Details

    • validateCheck

      private static void validateCheck(Check check)
      Throw an exception if check is not acceptable for this class.
      Parameters:
      check - the check that a client is trying to insert into this
    • count

      public int count()
      Description copied from interface: TestChecks
      Return the number of checks in this test.
      Specified by:
      count in interface TestChecks<ErrorRevealingChecks>
      Returns:
      the count of checks in this object
    • checks

      public Set<Check> checks()
      Get all non-exception checks and whether they are passing for this object.
      Specified by:
      checks in interface TestChecks<ErrorRevealingChecks>
      Returns:
      all checks, with each mapped to false, indicating it is failing
    • hasChecks

      public boolean hasChecks()
      Indicates whether this object has checks.
      Specified by:
      hasChecks in interface TestChecks<ErrorRevealingChecks>
      Returns:
      true if not empty
    • hasErrorBehavior

      public boolean hasErrorBehavior()
      Indicate whether this object has any failing checks. (This is essentially asking whether this is an error revealing test.)
      Specified by:
      hasErrorBehavior in interface TestChecks<ErrorRevealingChecks>
      Returns:
      true if there are any error revealing checks (not empty)
    • getExceptionCheck

      public ExceptionCheck getExceptionCheck()
      Return the exception check in this object if there is one.
      Specified by:
      getExceptionCheck in interface TestChecks<ErrorRevealingChecks>
      Returns:
      null, since no expected exceptions in error-revealing tests
    • add

      public void add(Check check)
      Add a check to this set.
      Specified by:
      add in interface TestChecks<ErrorRevealingChecks>
      Parameters:
      check - the check object to add to this set of checks
      Throws:
      Error - if check is an exception check
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • commonChecks

      public ErrorRevealingChecks commonChecks(ErrorRevealingChecks other)
      Description copied from interface: TestChecks
      Returns the intersection of checks in this set and another set.
      Specified by:
      commonChecks in interface TestChecks<ErrorRevealingChecks>
      Parameters:
      other - the TestChecks to compare with
      Returns:
      the checks common to this set of checks and those in other
    • hasInvalidBehavior

      public boolean hasInvalidBehavior()
      Indicates whether this set of checks contains any invalid behaviors.

      Returns false because error checks are not considered invalid.

      Specified by:
      hasInvalidBehavior in interface TestChecks<ErrorRevealingChecks>
      Returns:
      false, always
    • toString

      public String toString()
      Overrides:
      toString in class Object