/**
   * @return next test from test matrix: {varArgs, noVarArgs} x TestCase.rtypes x
   *     TestCase.THROWABLES x {1, .., maxArgs } x {1, .., maxDrops}
   */
  public CatchExceptionTest nextTest() {
    if (constructor < constructorSize) {
      return createTest();
    }
    constructor = 0;
    count++;
    if (!Helper.IS_THOROUGH && count > Helper.TEST_LIMIT) {
      System.out.println("test limit is exceeded");
      return null;
    }
    if (dropArgs <= currentMaxDrops) {
      if (dropArgs == 1) {
        if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) {
          ++dropArgs;
          return createTest();
        } else if (Helper.IS_VERBOSE) {
          System.out.printf("argsCount=%d : \"drop\" scenarios are skipped%n", args);
        }
      } else {
        ++dropArgs;
        return createTest();
      }
    }

    if (args <= maxArgs) {
      dropArgs = 1;
      currentMaxDrops = Math.min(args, maxDrops);
      ++args;
      return createTest();
    }
    return null;
  }
  public TestFactory() {
    if (Helper.IS_THOROUGH) {
      maxArgs = maxDrops = CatchExceptionTest.MAX_ARITY;
    } else {
      maxArgs =
          MIN_TESTED_ARITY
              + Helper.RNG.nextInt(CatchExceptionTest.MAX_ARITY - MIN_TESTED_ARITY)
              + 1;
      maxDrops = MIN_TESTED_ARITY + Helper.RNG.nextInt(maxArgs - MIN_TESTED_ARITY) + 1;
      args = 1;
    }

    if (Helper.IS_VERBOSE) {
      System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops);
    }
    constructorSize = TestCase.CONSTRUCTORS.size();
  }
 private CatchExceptionTest createTest() {
   if (!Helper.IS_THOROUGH) {
     return new CatchExceptionTest(
         TestCase.CONSTRUCTORS.get(constructor++).get(), Helper.RNG.nextBoolean(), args, dropArgs);
   } else {
     if (isVararg) {
       isVararg = false;
       return new CatchExceptionTest(
           TestCase.CONSTRUCTORS.get(constructor++).get(), isVararg, args, dropArgs);
     } else {
       isVararg = true;
       return new CatchExceptionTest(
           TestCase.CONSTRUCTORS.get(constructor).get(), isVararg, args, dropArgs);
     }
   }
 }