01: // Copyright © 2006-2007 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.plugins.exceltest;
03:
04: import com.canoo.webtest.steps.Step;
05:
06: /**
07: * Test class for {@link ExcelFindRow}.<p>
08: *
09: * @author Rob Nielsen
10: */
11: public class ExcelFindRowTest extends BaseExcelStepTestCase {
12: protected Step createStep() {
13: return new ExcelFindRow();
14: }
15:
16: public void testRequiredFields() {
17: final ExcelFindRow step = (ExcelFindRow) getStep();
18: step.setProperty("xxx");
19: step.setCol("A");
20: assertStepRejectsNullParam("text", step);
21: step.setText("blah");
22: step.setProperty(null);
23: assertStepRejectsNullParam("property", step);
24: step.setProperty("xxx");
25: step.setCol(null);
26: assertStepRejectsNullParam("col", step);
27: }
28:
29: public void testInvalidCol() {
30: final ExcelFindRow step = (ExcelFindRow) getStep();
31: step.setProperty("xxx");
32: step.setText("TOTAL");
33: step.setCol("InvalidColumn");
34: assertErrorOnExecute(step, "Invalid Column",
35: "Can't parse 'InvalidColumn' as a column reference (eg. 'A' or '1')");
36: step.setCol("0");
37: assertErrorOnExecute(step, "Invalid Column",
38: "Can't parse '0' as a column reference (eg. 'A' or '1')");
39: }
40:
41: public void testInvalidStartRow() {
42: final ExcelFindRow step = (ExcelFindRow) getStep();
43: step.setProperty("xxx");
44: step.setCol("A");
45: step.setStartRow("InvalidRow");
46: step.setText("xxx");
47: assertErrorOnExecute(step, "Invalid Row",
48: "Can't parse startRow parameter with value 'InvalidRow' as an integer.");
49: step.setStartRow("0");
50: assertErrorOnExecute(step, "Invalid Row",
51: "Can't parse '0' as a integer row reference.");
52: }
53:
54: public void testCantFindRow() {
55: final ExcelFindRow step = (ExcelFindRow) getStep();
56: step.setCol("A");
57: step.setText("blarg");
58: step.setProperty("test");
59: assertFailOnExecute(step, "FindRow",
60: "No cells were found matching 'blarg' starting from A1");
61: }
62:
63: }
|