001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.test;
020:
021: /**
022: * Defines the interface of a <tt>TestReport</tt> produced
023: * by a <tt>Test</tt> case.
024: *
025: * @author <a href="mailto:vhardy@apache.lorg">Vincent Hardy</a>
026: * @version $Id: TestReport.java 482121 2006-12-04 10:00:39Z dvholten $
027: */
028: public interface TestReport {
029: /**
030: * Error code to be used when a <tt>Test</tt> fails in
031: * its own operation (i.e., the <tt>Test</tt> itself
032: * fails, not what it is testing. An internal failure
033: * is reported when any type of exception occurs while
034: * running the test.
035: */
036: String ERROR_INTERNAL_TEST_FAILURE = "TestReport.error.internal.test.failure";
037:
038: /**
039: * Very generic error code which can be used to report
040: * that the test failed.
041: */
042: String ERROR_TEST_FAILED = "TestReport.error.test.failed";
043:
044: /**
045: * Generic error code to report test assertion failures.
046: */
047: String ERROR_ASSERTION_FAILED = "TestReport.error.assertion.failed";
048:
049: /**
050: * Entry describing the class of the internal exception
051: * that caused the test's internal failure
052: */
053: String ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_CLASS = "TestReport.entry.key.internal.test.failure.exception.class";
054:
055: /**
056: * Entry describing the messages of the internal exception
057: * that caused the test's internal failure
058: */
059: String ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_MESSAGE = "TestReport.entry.key.internal.test.failure.exception.message";
060:
061: /**
062: * Entry with the stack trace for the internal exception
063: * that caused the test's internal failure
064: */
065: String ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_STACK_TRACE = "TestReport.entry.key.internal.test.failure.exception.stack.trace";
066:
067: /**
068: * Entry with the class of the exception that caused the test to fail.
069: * Note that this is different from
070: * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_CLASS, in
071: * which case, the test itself failed unexpectedly. In this
072: * case, the entry is used to describe an expected exception
073: * for which the <tt>Test</tt> author probably created a
074: * specific error code.
075: */
076: String ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_CLASS = "TestReport.entry.key.reported.test.failure.exception.class";
077:
078: /**
079: * Entry with the message of the exception that caused the test to fail.
080: * Note that this is different from
081: * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_MESSAGE, in
082: * which case, the test itself failed unexpectedly. In this
083: * case, the entry is used to describe an expected exception
084: * for which the <tt>Test</tt> author probably created a
085: * specific error code.
086: */
087: String ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_MESSAGE = "TestReport.entry.key.reported.test.failure.exception.message";
088:
089: /**
090: * Entry with the stack trace that caused the test to fail.
091: * Note that this is different from
092: * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_STACK_TRACE, in
093: * which case, the test itself failed unexpectedly. In this
094: * case, the entry is used to describe an expected exception
095: * for which the <tt>Test</tt> author probably created a
096: * specific error code.
097: */
098: String ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_STACK_TRACE = "TestReport.entry.key.reported.test.failure.exception.stack.trace";
099:
100: /**
101: * Entry with the stack trace for a specific test error
102: * condition.
103: */
104: String ENTRY_KEY_ERROR_CONDITION_STACK_TRACE = "TestReport.entry.key.error.condition.stack.trace";
105:
106: /**
107: * Inner class for describing an information element in a
108: * <tt>TestReport</tt>
109: */
110: class Entry {
111: private String entryKey;
112: private Object entryValue;
113:
114: public Entry(String entryKey, Object entryValue) {
115: this .entryKey = entryKey;
116: this .entryValue = entryValue;
117: }
118:
119: public final String getKey() {
120: return entryKey;
121: }
122:
123: public final Object getValue() {
124: return entryValue;
125: }
126: }
127:
128: /**
129: * Returns the overall test result
130: */
131: boolean hasPassed();
132:
133: /**
134: * Returns the error code. This should never be null
135: * if the test failed (i.e., if hasPassed returns false).
136: */
137: String getErrorCode();
138:
139: /**
140: * Returns an array of <tt>Entry</tt> objects describing the
141: * test result.
142: * Accepted value types are <tt>String</tt> objects, <tt>URL</tt>
143: * objects, <tt>File</tt> objects and <tt>TestReport</tt> objects.
144: * <tt>File</tt> objects should be considered as temporary files
145: */
146: Entry[] getDescription();
147:
148: /**
149: * Appends <tt>entry</tt> to the array of description entry.
150: */
151: void addDescriptionEntry(String key, Object value);
152:
153: /**
154: * Returns the <tt>Test</tt> object that generated this
155: * <tt>TestReport</tt>
156: */
157: Test getTest();
158:
159: /**
160: * Returns the parent report in case this <tt>TestReport</tt> is
161: * part of a <tt>TestSuiteReport</tt>. This may be null.
162: */
163: TestSuiteReport getParentReport();
164:
165: /**
166: * Set this report's parent.
167: */
168: void setParentReport(TestSuiteReport parent);
169: }
|