KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > ui > TestRunInfo


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.internal.junit.ui;
12
13 /**
14  * Store information about an executed test.
15  */

16 public class TestRunInfo extends Object JavaDoc {
17     private String JavaDoc fTestId;
18     private String JavaDoc fTestName;
19     private String JavaDoc fTrace;
20     private String JavaDoc fExpected;
21     private String JavaDoc fActual;
22     
23     private int fStatus;
24
25     public TestRunInfo(String JavaDoc testId, String JavaDoc testName){
26         fTestName= testName;
27         fTestId= testId;
28     }
29     
30     /*
31      * @see Object#hashCode()
32      */

33     public int hashCode() {
34         return getTestId().hashCode();
35     }
36
37     /*
38      * @see Object#equals(Object)
39      */

40     public boolean equals(Object JavaDoc obj) {
41         return getTestId().equals(obj);
42     }
43
44     public String JavaDoc getTestId() {
45         return fTestId;
46     }
47
48     public String JavaDoc getTestName() {
49         return fTestName;
50     }
51
52     public String JavaDoc getClassName() {
53         return extractClassName(getTestName());
54     }
55     
56     public String JavaDoc getTestMethodName() {
57         int index= fTestName.indexOf('(');
58         if (index > 0)
59             return fTestName.substring(0, index);
60         index= fTestName.indexOf('@');
61         if(index > 0)
62             return fTestName.substring(0, index);
63         return fTestName;
64     }
65     
66     private String JavaDoc extractClassName(String JavaDoc testNameString) {
67         if (testNameString == null)
68             return null;
69         int index= testNameString.indexOf('(');
70         if (index < 0)
71             return testNameString;
72         testNameString= testNameString.substring(index + 1);
73         return testNameString.substring(0, testNameString.indexOf(')'));
74     }
75
76     public void setTrace(String JavaDoc trace) {
77         fTrace= trace;
78     }
79
80     public String JavaDoc getTrace() {
81         return fTrace;
82     }
83
84     public void setStatus(int status) {
85         fStatus= status;
86     }
87
88     public int getStatus() {
89         return fStatus;
90     }
91     
92     public String JavaDoc getActual() {
93         return fActual;
94     }
95     
96     public void setActual(String JavaDoc actual) {
97         fActual = actual;
98     }
99     
100     public String JavaDoc getExpected() {
101         return fExpected;
102     }
103     
104     public void setExpected(String JavaDoc expected) {
105         fExpected = expected;
106     }
107     
108     public boolean isComparisonFailure() {
109         return fExpected != null && fActual != null;
110     }
111 }
112
Popular Tags