KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > test > TestReport


1 /*
2
3    Copyright 2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.test;
19
20 /**
21  * Defines the interface of a <tt>TestReport</tt> produced
22  * by a <tt>Test</tt> case.
23  *
24  * @author <a HREF="mailto:vhardy@apache.lorg">Vincent Hardy</a>
25  * @version $Id: TestReport.java,v 1.6 2004/08/18 07:16:58 vhardy Exp $
26  */

27 public interface TestReport {
28     /**
29      * Error code to be used when a <tt>Test</tt> fails in
30      * its own operation (i.e., the <tt>Test</tt> itself
31      * fails, not what it is testing. An internal failure
32      * is reported when any type of exception occurs while
33      * running the test.
34      */

35     public static final String JavaDoc ERROR_INTERNAL_TEST_FAILURE
36         = "TestReport.error.internal.test.failure";
37
38     /**
39      * Very generic error code which can be used to report
40      * that the test failed.
41      */

42     public static final String JavaDoc ERROR_TEST_FAILED
43         = "TestReport.error.test.failed";
44
45     /**
46      * Generic error code to report test assertion failures.
47      */

48     public static final String JavaDoc ERROR_ASSERTION_FAILED
49         = "TestReport.error.assertion.failed";
50
51     /**
52      * Entry describing the class of the internal exception
53      * that caused the test's internal failure
54      */

55     public static final String JavaDoc
56         ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_CLASS
57         = "TestReport.entry.key.internal.test.failure.exception.class";
58
59     /**
60      * Entry describing the messages of the internal exception
61      * that caused the test's internal failure
62      */

63     public static final String JavaDoc
64         ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_MESSAGE
65         = "TestReport.entry.key.internal.test.failure.exception.message";
66
67     /**
68      * Entry with the stack trace for the internal exception
69      * that caused the test's internal failure
70      */

71     public static final String JavaDoc
72         ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_STACK_TRACE
73         = "TestReport.entry.key.internal.test.failure.exception.stack.trace";
74
75     /**
76      * Entry with the class of the exception that caused the test to fail.
77      * Note that this is different from
78      * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_CLASS, in
79      * which case, the test itself failed unexpectedly. In this
80      * case, the entry is used to describe an expected exception
81      * for which the <tt>Test</tt> author probably created a
82      * specific error code.
83      */

84     public static final String JavaDoc
85         ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_CLASS
86         = "TestReport.entry.key.reported.test.failure.exception.class";
87
88     /**
89      * Entry with the message of the exception that caused the test to fail.
90      * Note that this is different from
91      * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_MESSAGE, in
92      * which case, the test itself failed unexpectedly. In this
93      * case, the entry is used to describe an expected exception
94      * for which the <tt>Test</tt> author probably created a
95      * specific error code.
96      */

97     public static final String JavaDoc
98         ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_MESSAGE
99         = "TestReport.entry.key.reported.test.failure.exception.message";
100
101     /**
102      * Entry with the stack trace that caused the test to fail.
103      * Note that this is different from
104      * ENTRY_KEY_INTERNAL_TEST_FAILURE_EXCEPTION_STACK_TRACE, in
105      * which case, the test itself failed unexpectedly. In this
106      * case, the entry is used to describe an expected exception
107      * for which the <tt>Test</tt> author probably created a
108      * specific error code.
109      */

110     public static final String JavaDoc
111         ENTRY_KEY_REPORTED_TEST_FAILURE_EXCEPTION_STACK_TRACE
112         = "TestReport.entry.key.reported.test.failure.exception.stack.trace";
113
114     /**
115      * Entry with the stack trace for a specific test error
116      * condition.
117      */

118     public static final String JavaDoc
119         ENTRY_KEY_ERROR_CONDITION_STACK_TRACE
120         = "TestReport.entry.key.error.condition.stack.trace";
121
122     /**
123      * Inner class for describing an information element in a
124      * <tt>TestReport</tt>
125      */

126     public static class Entry {
127         private String JavaDoc entryKey;
128         private Object JavaDoc entryValue;
129
130         public Entry(String JavaDoc entryKey,
131                      Object JavaDoc entryValue){
132             this.entryKey = entryKey;
133             this.entryValue = entryValue;
134         }
135
136         public final String JavaDoc getKey(){
137             return entryKey;
138         }
139
140         public final Object JavaDoc getValue(){
141             return entryValue;
142         }
143     }
144
145     /**
146      * Returns the overall test result
147      */

148     public boolean hasPassed();
149
150     /**
151      * Returns the error code. This should never be null
152      * if the test failed (i.e., if hasPassed returns false).
153      */

154     public String JavaDoc getErrorCode();
155
156     /**
157      * Returns an array of <tt>Entry</tt> objects describing the
158      * test result.
159      * Accepted value types are <tt>String</tt> objects, <tt>URL</tt>
160      * objects, <tt>File</tt> objects and <tt>TestReport</tt> objects.
161      * <tt>File</tt> objects should be considered as temporary files
162      */

163     public Entry[] getDescription();
164
165     /**
166      * Appends <tt>entry</tt> to the array of description entry.
167      */

168     public void addDescriptionEntry(String JavaDoc key,
169                                     Object JavaDoc value);
170
171     /**
172      * Returns the <tt>Test</tt> object that generated this
173      * <tt>TestReport</tt>
174      */

175     public Test getTest();
176
177     /**
178      * Returns the parent report in case this <tt>TestReport</tt> is
179      * part of a <tt>TestSuiteReport</tt>. This may be null.
180      */

181     public TestSuiteReport getParentReport();
182
183     /**
184      * Set this report's parent.
185      */

186     public void setParentReport(TestSuiteReport parent);
187 }
188
Popular Tags