01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fit;
04:
05: import junit.framework.TestCase;
06:
07: public class FriendlyErrorTest extends TestCase {
08: // Test the FitFailureException mechanism. If this works, then all of the
09: // FitFailureException derivatives ought
10: // to be working too.
11: public void testCantFindFixture() throws Exception {
12: String pageString = "<table><tr><td>NoSuchFixture</td></tr></table>";
13: Parse page = new Parse(pageString);
14: Fixture fixture = new Fixture();
15: fixture.doTables(page);
16: String fixtureName = page.at(0, 0, 0).body;
17: assertTrue(fixtureName
18: .indexOf("Could not find fixture: NoSuchFixture.") != -1);
19: }
20:
21: public void testNoSuchMethod() throws Exception {
22: final String[][] table = {
23: { "fitnesse.fixtures.ColumnFixtureTestFixture" },
24: { "no such method?" } };
25: Parse page = FixtureTest.executeFixture(table);
26: String columnHeader = page.at(0, 1, 0).body;
27: assertTrue(columnHeader
28: .indexOf("Could not find method: no such method?.") != -1);
29: }
30:
31: public void testParseFailure() throws Exception {
32: final String[][] table = {
33: { "fitnesse.fixtures.ColumnFixtureTestFixture" },
34: { "input", "output?" }, { "1", "alpha" } };
35: Parse page = FixtureTest.executeFixture(table);
36: String colTwoResult = page.at(0, 2, 1).body;
37: assertTrue(colTwoResult
38: .indexOf("Could not parse: alpha expected type: int") != -1);
39: }
40:
41: public void testExceptionInMethod() throws Exception {
42: final String[][] table = {
43: { "fitnesse.fixtures.ColumnFixtureTestFixture" },
44: { "input", "exception?" }, { "1", "true" } };
45: Parse page = FixtureTest.executeFixture(table);
46: String colTwoResult = page.at(0, 2, 1).body;
47: assertTrue(colTwoResult.indexOf("I thowed up") != -1);
48: }
49: }
|