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 ExcelVerifyCellSum}.<p>
08: *
09: * @author Rob Nielsen
10: */
11: public class ExcelVerifyCellSumTest extends BaseExcelStepTestCase {
12: protected Step createStep() {
13: return new ExcelVerifyCellSum();
14: }
15:
16: public void testSuccess() throws Exception {
17: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
18: step.setCell("C8");
19: step.setRange("C4:C7");
20: executeStep(step);
21: }
22:
23: public void testFailVerifyCellSumWithNumber() throws Exception {
24: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
25: step.setCell("C8");
26: step.setRange("C5:C7");
27: assertFailOnExecute(
28: step,
29: "verify with number",
30: "Unexpected sum of cells from range C5:C7 in cell C8. Expected value \"15.0\" but got \"16.0\"");
31: }
32:
33: public void testFailVerifyCellSumWithFormula() throws Exception {
34: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
35: step.setCell("E8");
36: step.setRange("F5:F9");
37: assertFailOnExecute(
38: step,
39: "verify with formula",
40: "Unexpected formula in cell E8. Expected value \"SUM(F5:F9)\" but got \"SUM(E4:E7)\"");
41: }
42:
43: public void testFailVerifyCellSumWithTextInTarget()
44: throws Exception {
45: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
46: step.setCell("B8");
47: step.setRange("C4:C7");
48: assertFailOnExecute(step, "verify text target",
49: "Cell B8 does not contain a formula or a numeric value.");
50: }
51:
52: public void testFailVerifyCellSumWithTextInRange() throws Exception {
53: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
54: step.setCell("C8");
55: step.setRange("B4:B8");
56: assertFailOnExecute(step, "verify text range",
57: "Cell B4 does not contain a numeric value.");
58: }
59:
60: public void testInvalidRange() throws Exception {
61: final ExcelVerifyCellSum step = (ExcelVerifyCellSum) getStep();
62: step.setCell("C8");
63: step.setRange("blah");
64: assertErrorOnExecute(step, "verify text range",
65: "Cannot parse \"blah\" as a spreadsheet range. eg \"A10:A20\"");
66: }
67: }
|