1 /*
2 * Copyright 2007 united internet (unitedinternet.com) Robert Zimmermann
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 */
17 package com.unitedinternet.portal.selenium.utils.logging;
18
19 /**
20 * The LoggingResultFormatter can be used to log in any format you want to.
21 *
22 * The formatter is responsible for writing results.
23 *
24 * Also the formatter is resposible for handling encodings right for whatever output storage is used.
25 *
26 * Currently there is an HtmlResultFormatter implemented. There could also be an CSVFormatter, DatabaseFormatter or whatever you
27 * want the log to look like.
28 *
29 * @author Robert Zimmermann
30 *
31 * $Id: LoggingResultsFormatter.java 116 2008-05-02 13:43:44Z Steffen_K $
32 */
33 public interface LoggingResultsFormatter {
34 /**
35 * Format a comment.
36 *
37 * Comments may be issued between commands by the loggingCommandProcessor, like a new method has been entered by the test.
38 *
39 * @param loggingBean loggingBean containing the comment to be logged.
40 */
41 void commentLogEvent(LoggingBean loggingBean);
42
43 /**
44 * Formats an selenium command.
45 *
46 * @param loggingBean containing all informations for logging a selenium command
47 */
48 void commandLogEvent(LoggingBean loggingBean);
49
50 /**
51 * Formats an selenium command which has an boolean result.
52 *
53 * Important: At this state no information whether an false or true result was or is expected by the test using this
54 * formatter. So an false result may be "green" for the test. Therefore all log-events here are logged as green.
55 *
56 * e.g. selenium commands like isElementPresent
57 *
58 * @param loggingBean containing all informations for logging a selenium command
59 */
60 void booleanCommandLogEvent(LoggingBean loggingBean);
61
62 /**
63 * Formats a Log Event for a complete Test Method.
64 *
65 * The Logging Bean may contain several child beans holding the information of the single selenium commands.
66 *
67 * @param loggingBean containing all informations for logging a test method and its commands
68 */
69 void methodLogEvent(LoggingBean loggingBean);
70
71 /**
72 * Whatever the formatter wants to do before any command will be formatted.
73 *
74 * @param metricsBean metrics gathered during test-run
75 */
76 void headerLogEvent(TestMetricsBean metricsBean);
77
78 /**
79 * Like formatHeader() but here after all commands have been formatted.
80 */
81 void footerLogEvent();
82
83 /**
84 * Base URI to be linked to in the result.
85 *
86 * Screenshots may be linked with an http or similar prefix to be easier accessible in whatever reporting frontend is used
87 * later
88 *
89 * @return the current base-uri for screenshots
90 */
91 String getScreenShotBaseUri();
92
93 /**
94 * Set a special uri for screenshots.
95 *
96 * @param screenShotBaseUri the new uri for screenshots
97 */
98 void setScreenShotBaseUri(String screenShotBaseUri);
99
100 /**
101 * Generate an absolute filename for taking screenshots in case of an error (eg. timed out wait).
102 *
103 * @param baseName middle part of the name to be enhanced by whatever the implementation wants to
104 * @return absolute path for screenshot to be taken
105 */
106 String generateFilenameForAutomaticScreenshot(String baseName);
107
108 /**
109 * Path to the (filesystem-)location where screenshot should be saved. Will be used by
110 * generateFilenameForAutomaticScreenshot()
111 *
112 * @return current location path
113 */
114 String getAutomaticScreenshotPath();
115
116 /**
117 * Path to the (filesystem-)location where screenshot should be saved. Will be used by
118 * generateFilenameForAutomaticScreenshot()
119 *
120 * @param automaticScreenshotPath location (only path) to where screenshots should be saved
121 */
122 void setAutomaticScreenshotPath(String automaticScreenshotPath);
123 }