KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > junit > model > ITestElement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.junit.model;
12
13
14 /**
15  * Common protocol for test elements.
16  * This set consists of {@link ITestCaseElement} , {@link ITestSuiteElement} and {@link ITestRunSession}
17  *
18  * <p>
19  * This interface is not intended to be implemented by clients.
20  * </p>
21  *
22  *
23  * @since 3.3
24  */

25 public interface ITestElement {
26     
27     /**
28      * Running states of a test.
29      */

30     public static final class ProgressState {
31         /** state that describes that the test element has not started */
32         public static final ProgressState NOT_STARTED= new ProgressState("Not Started"); //$NON-NLS-1$
33
/** state that describes that the test element has is running */
34         public static final ProgressState RUNNING= new ProgressState("Running"); //$NON-NLS-1$
35
/** state that describes that the test element has been stopped before being completed */
36         public static final ProgressState STOPPED= new ProgressState("Stopped"); //$NON-NLS-1$
37
/** state that describes that the test element has completed */
38         public static final ProgressState COMPLETED= new ProgressState("Completed"); //$NON-NLS-1$
39

40         private String JavaDoc fName;
41         private ProgressState(String JavaDoc name) {
42             fName= name;
43         }
44         public String JavaDoc toString() {
45             return fName;
46         }
47     }
48     
49     /**
50      * Result states of a test.
51      */

52     public static final class Result {
53         /** state that describes that the test result is undefined */
54         public static final Result UNDEFINED= new Result("Undefined"); //$NON-NLS-1$
55
/** state that describes that the test result is 'OK' */
56         public static final Result OK= new Result("OK"); //$NON-NLS-1$
57
/** state that describes that the test result is 'Error' */
58         public static final Result ERROR= new Result("Error"); //$NON-NLS-1$
59
/** state that describes that the test result is 'Failure' */
60         public static final Result FAILURE= new Result("Failure"); //$NON-NLS-1$
61
/** state that describes that the test result is 'Ignored' */
62         public static final Result IGNORED= new Result("Ignored"); //$NON-NLS-1$
63

64         private String JavaDoc fName;
65         private Result(String JavaDoc name) {
66             fName= name;
67         }
68         public String JavaDoc toString() {
69             return fName;
70         }
71     }
72     
73     /**
74      * A failure trace of a test.
75      *
76      * This class is not intended to be instantiated or extended by clients.
77      */

78     public static final class FailureTrace {
79         private final String JavaDoc fActual;
80         private final String JavaDoc fExpected;
81         private final String JavaDoc fTrace;
82
83         public FailureTrace(String JavaDoc trace, String JavaDoc expected, String JavaDoc actual) {
84             fActual= actual;
85             fExpected= expected;
86             fTrace= trace;
87         }
88         
89         /**
90          * Returns the failure stack trace.
91          *
92          * @return the failure stack trace
93          */

94         public String JavaDoc getTrace() {
95             return fTrace;
96         }
97         
98         /**
99          * Returns the expected result or <code>null</code> if the trace is not a comparison failure.
100          *
101          * @return the expected result or <code>null</code> if the trace is not a comparison failure.
102          */

103         public String JavaDoc getExpected() {
104             return fExpected;
105         }
106         
107         /**
108          * Returns the actual result or <code>null</code> if the trace is not a comparison failure.
109          *
110          * @return the actual result or <code>null</code> if the trace is not a comparison failure.
111          */

112         public String JavaDoc getActual() {
113             return fActual;
114         }
115     }
116     
117     /**
118      * Returns the progress state of this test element.
119      * <dl>
120      * <li>{@link ITestElement.ProgressState#NOT_STARTED}: the test has not yet started</li>
121      * <li>{@link ITestElement.ProgressState#RUNNING}: the test is currently running</li>
122      * <li>{@link ITestElement.ProgressState#STOPPED}: the test has stopped before being completed</li>
123      * <li>{@link ITestElement.ProgressState#COMPLETED}: the test (and all its children) has completed</li>
124      * </dl>
125      * @return returns one of {@link ITestElement.ProgressState#NOT_STARTED}, {@link ITestElement.ProgressState#RUNNING},
126      * {@link ITestElement.ProgressState#STOPPED} or {@link ITestElement.ProgressState#COMPLETED}.
127      */

128     public ProgressState getProgressState();
129     
130     /**
131      * Returns the result of the test element.
132      * <dl>
133      * <li>{@link ITestElement.Result#UNDEFINED}: the result is not yet evaluated</li>
134      * <li>{@link ITestElement.Result#OK}: the test has succeeded</li>
135      * <li>{@link ITestElement.Result#ERROR}: the test has returned an error</li>
136      * <li>{@link ITestElement.Result#FAILURE}: the test has returned an failure</li>
137      * <li>{@link ITestElement.Result#IGNORED}: the test has been ignored (skipped)</li>
138      * </dl>
139      * @param includeChildren if <code>true</code>, the returned result is the combined
140      * result of the test and its children (if it has any). If <code>false</code>,
141      * only the test's result is returned.
142      *
143      * @return returns one of {@link ITestElement.Result#UNDEFINED}, {@link ITestElement.Result#OK}, {@link ITestElement.Result#ERROR},
144      * {@link ITestElement.Result#FAILURE} or {@link ITestElement.Result#IGNORED}. Clients should also prepare for other, new values.
145      */

146     public Result getTestResult(boolean includeChildren);
147     
148     /**
149      * Returns the failure trace of this test element or <code>null</code> if the test has not resulted in an error or failure.
150      *
151      * @return the failure trace of this test or <code>null</code>.
152      */

153     public FailureTrace getFailureTrace();
154         
155     /**
156      * Returns the parent test element container or <code>null</code> if the test element is the test run session.
157      *
158      * @return the parent test suite
159      */

160     public ITestElementContainer getParentContainer();
161     
162     /**
163      * Returns the test run session.
164      *
165      * @return the parent test run session.
166      */

167     public ITestRunSession getTestRunSession();
168     
169 }
170
Popular Tags