01: // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
02: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
03: // Released under the terms of the GNU General Public License version 2 or later.
04: package fit;
05:
06: import junit.framework.TestCase;
07:
08: public class FriendlyErrorTest extends TestCase {
09: //Test the FitFailureException mechanism. If this works, then all of the 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: }
|