@Test public void testCalculateRunsWhenThereIsOnlyOneFeeder() { String className = "com.epam.test.TestClass"; int count = 2; int expected = 4; Whitebox.setInternalState(underTest, "feeder", feeder); Whitebox.setInternalState(underTest, "nextDataFeederLoader", null); given(feeder.calculateRuns(className, count)).willReturn(expected); int actual = underTest.calculateRuns(className, count); Assert.assertEquals(expected, actual); }
public int calculateRuns(final String className, final int count) { if (feeder == null) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class: " + feederClassName + " getTotalRuns() method was failed, because the feeder class is missing" + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_MISSING); } int newCount = feeder.calculateRuns(className, count); if (newCount <= 0) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class" + feederClassName + " getTotalRuns() method" + " was failed with error code: " + newCount + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_ERROR); } if (nextDataFeederLoader != null) { newCount = nextDataFeederLoader.calculateRuns(className, newCount); } return newCount; }
DataFeederLoader { public int calculateRuns(final String className, final int count) { if (feeder == null) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class: " + feederClassName + " getTotalRuns() method was failed, because the feeder class is missing" + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_MISSING); } int newCount = feeder.calculateRuns(className, count); if (newCount <= 0) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class" + feederClassName + " getTotalRuns() method" + " was failed with error code: " + newCount + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_ERROR); } if (nextDataFeederLoader != null) { newCount = nextDataFeederLoader.calculateRuns(className, newCount); } return newCount; } }
DataFeederLoader { public int calculateRuns(final String className, final int count) { if (feeder == null) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class: " + feederClassName + " getTotalRuns() method was failed, because the feeder class is missing" + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_MISSING); } int newCount = feeder.calculateRuns(className, count); if (newCount <= 0) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class" + feederClassName + " getTotalRuns() method" + " was failed with error code: " + newCount + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_ERROR); } if (nextDataFeederLoader != null) { newCount = nextDataFeederLoader.calculateRuns(className, newCount); } return newCount; } DataFeederLoader(final String className, final String feederDescriptor, final Environment environment); }
DataFeederLoader { public int calculateRuns(final String className, final int count) { if (feeder == null) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class: " + feederClassName + " getTotalRuns() method was failed, because the feeder class is missing" + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_MISSING); } int newCount = feeder.calculateRuns(className, count); if (newCount <= 0) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class" + feederClassName + " getTotalRuns() method" + " was failed with error code: " + newCount + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_ERROR); } if (nextDataFeederLoader != null) { newCount = nextDataFeederLoader.calculateRuns(className, newCount); } return newCount; } DataFeederLoader(final String className, final String feederDescriptor, final Environment environment); int calculateRuns(final String className, final int count); DataDrivenParameters getParameterRow(final String className, final int drivenDataRowNo); DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray); void reserveParameterArray(final DataDrivenParameterArray parameterArray); static void reportError(final String message); static void reportException(final String message, final Exception e); }
DataFeederLoader { public int calculateRuns(final String className, final int count) { if (feeder == null) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class: " + feederClassName + " getTotalRuns() method was failed, because the feeder class is missing" + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_MISSING); } int newCount = feeder.calculateRuns(className, count); if (newCount <= 0) { AllTestRunner.CONSOLE_LOG.info("\nERROR: Data Feeder Class" + feederClassName + " getTotalRuns() method" + " was failed with error code: " + newCount + " at Class in testlist: " + className + "\nPlease fix it!\nNow exiting..."); throw new ShutDownException(ExitCode.EXIT_CODE_DATA_FEEDER_CLASS_ERROR); } if (nextDataFeederLoader != null) { newCount = nextDataFeederLoader.calculateRuns(className, newCount); } return newCount; } DataFeederLoader(final String className, final String feederDescriptor, final Environment environment); int calculateRuns(final String className, final int count); DataDrivenParameters getParameterRow(final String className, final int drivenDataRowNo); DataDrivenParameterArray calculateParameterArray(final String className, final DataDrivenParameterArray inputParameterArray); void reserveParameterArray(final DataDrivenParameterArray parameterArray); static void reportError(final String message); static void reportException(final String message, final Exception e);  }