### Question:
ExcelReader { public List<Row> getAllExcelRows(String sheetName, boolean heading) { logger.entering(new Object[] { sheetName, heading }); Sheet sheet = fetchSheet(sheetName); int numRows = sheet.getPhysicalNumberOfRows(); List<Row> rows = new ArrayList<Row>(); int currentRow = 1; if (heading) { currentRow = 0; } int rowCount = 1; while (currentRow <= numRows) { Row row = sheet.getRow(currentRow); if (row != null) { Cell cell = row.getCell(0); if (cell != null) { if (!cell.toString().contains("#")) { rows.add(row); } rowCount = rowCount + 1; } } currentRow = currentRow + 1; } logger.exiting(rows); return rows; } ExcelReader(DataResource resource); List<Row> getAllExcelRows(String sheetName, boolean heading); boolean sheetExists(String sheetName); List<String> getRowContents(String sheetName, int rowIndex, int size); List<String> getHeaderRowContents(String sheetName, int size); List<String> getRowContents(Row row, int size); int getRowIndex(String sheetName, String key); Row getAbsoluteSingeExcelRow(String sheetName, int rowNumber);  }### Answer:
@Test(groups = "unit", expectedExceptions = { IllegalArgumentException.class }) public void testInvalidSheetName() { excelReader.getAllExcelRows("IAmNotThere", false); }
@Test(groups = "unit") public void testGetAllExcelRowsSkippingOfRows() { assertTrue(excelReader.getAllExcelRows("Sheet1", false).isEmpty()); }
@Test(groups = "unit") public void testGetAllExcelRowsAndCheckIfHeadingRowIsRead() { assertTrue(excelReader.getAllExcelRows("Sheet1", true).size() == 1); }
@Test(groups = "unit") public void testGetAllExcelRows() { List<Row> row = excelReader.getAllExcelRows("USER", true); assertEquals(row.size(), 6, "Failed reading all rows from spreadsheet"); row = excelReader.getAllExcelRows("ADDRESS", false); assertEquals(row.size(), 3, "Failed reading all rows from spreadsheet"); }