View Javadoc

1   /*
2    * Copyright 2010-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.testdoc.report.junit;
17  
18  import java.io.Serializable;
19  
20  import de.smartics.testdoc.core.doc.Type;
21  
22  /**
23   * Contains the information of one JUnit test case result.
24   *
25   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
26   * @version $Revision:591 $
27   */
28  public class JUnitTestMethodDoc implements Serializable
29  {
30    // ********************************* Fields *********************************
31  
32    // --- constants ------------------------------------------------------------
33  
34    /**
35     * The class version identifier.
36     * <p>
37     * The value of this constant is {@value}.
38     * </p>
39     */
40    private static final long serialVersionUID = 1L;
41  
42    // --- members --------------------------------------------------------------
43  
44    /**
45     * The result type of the test case.
46     *
47     * @serial
48     */
49    private final ResultType resultType;
50  
51    /**
52     * The reported duration of the test case execution.
53     *
54     * @serial
55     */
56    private final String time;
57  
58    /**
59     * The type of the test case class that contains the test method.
60     *
61     * @serial
62     */
63    private final Type testCaseType;
64  
65    /**
66     * The name of the test method.
67     *
68     * @serial
69     */
70    private final String testMethodName;
71  
72    // ****************************** Initializer *******************************
73  
74    // ****************************** Constructors ******************************
75  
76    /**
77     * Convenience constructor.
78     *
79     * @param resultType the result type of the test case.
80     * @param time the reported duration of the test case execution.
81     * @param testCaseType
82     * @param testMethodName the name of the test method.
83     */
84    public JUnitTestMethodDoc(final ResultType resultType, final String time,
85        final String testCaseType, final String testMethodName)
86    {
87      this(resultType, time, new Type(testCaseType), testMethodName);
88    }
89  
90    /**
91     * Default constructor.
92     *
93     * @param resultType the result type of the test case.
94     * @param time the reported duration of the test case execution.
95     * @param testCaseType the type of the test case class that contains the test
96     *          method.
97     * @param testMethodName the name of the test method.
98     */
99    public JUnitTestMethodDoc(final ResultType resultType, final String time,
100       final Type testCaseType, final String testMethodName)
101   {
102     this.resultType = resultType;
103     this.time = time;
104     this.testCaseType = testCaseType;
105     this.testMethodName = testMethodName;
106   }
107 
108   // ****************************** Inner Classes *****************************
109 
110   /**
111    * The result type of the test case.
112    */
113   public static enum ResultType
114   {
115     /**
116      * The test has been run successfully.
117      */
118     SUCCESS,
119 
120     /**
121      * The test has been skipped.
122      */
123     SKIPPED,
124 
125     /**
126      * The test ran into a failure.
127      */
128     FAILURE,
129 
130     /**
131      * The test ran into an error.
132      */
133     ERROR;
134   }
135 
136   // ********************************* Methods ********************************
137 
138   // --- init -----------------------------------------------------------------
139 
140   // --- get&set --------------------------------------------------------------
141 
142   /**
143    * Returns the result type of the test case.
144    *
145    * @return the result type of the test case.
146    */
147   public ResultType getResultType()
148   {
149     return resultType;
150   }
151 
152   /**
153    * Returns the reported duration of the test case execution.
154    *
155    * @return the reported duration of the test case execution.
156    */
157   public String getTime()
158   {
159     return time;
160   }
161 
162   /**
163    * Returns the type of the test case class that contains the test method.
164    *
165    * @return the type of the test case class that contains the test method.
166    */
167   public Type getTestCaseType()
168   {
169     return testCaseType;
170   }
171 
172   /**
173    * Returns the name of the test method.
174    *
175    * @return the name of the test method.
176    */
177   public String getTestMethodName()
178   {
179     return testMethodName;
180   }
181 
182   // --- business -------------------------------------------------------------
183 
184   // --- object basics --------------------------------------------------------
185 
186 }