001/**
002 * ////////////////////////////////////////////////////////////////////////////////
003 * //
004 * //  D SOFTWARE INCORPORATED
005 * //  Copyright 2007-2014 D Software Incorporated
006 * //  All Rights Reserved.
007 * //
008 * //  NOTICE: D Software permits you to use, modify, and distribute this file
009 * //  in accordance with the terms of the license agreement accompanying it.
010 * //
011 * //  Unless required by applicable law or agreed to in writing, software
012 * //  distributed under the License is distributed on an "AS IS" BASIS,
013 * //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * //
015 * ////////////////////////////////////////////////////////////////////////////////
016 */
017package com.thed.launcher;
018
019
020import com.thed.model.Agent;
021import com.thed.model.TestcaseBatchExecution;
022import com.thed.model.TestcaseExecution;
023import org.apache.commons.configuration.PropertiesConfiguration;
024
025/**
026 * This interface is the parent class for all the ZBot interceptors. It contains methods that are executed
027 * in a particular sequence by {@link ScriptProcessor#run()} as explained below. These methods allow complete
028 * control over testcase execution flow and can optionally be overridden in custom interceptor.
029 * <br/>
030 *
031 * @see ScriptProcessor#run()
032 */
033
034/*
035 * Functionality of this class is similar to JUnit testcases.
036 * Methods are listed in the order of life cycle.
037 */
038public interface IZBotScriptLauncher {
039
040        /*----------------------------------------------------------
041         * LIFE CYCLE METHODS
042         *----------------------------------------------------------*/
043
044        /**
045         * This method is invoked once before start of testcase batch execution.
046         * Any kind of initial setup activity can be performed here. for example checking out scripts
047         * from version control systems(SVN) or databases, information to be written to logs for
048         * recording startup activity, etc.
049         * <br/>
050         * The TestcaseBatchExecution object is set in the {@link ScriptProcessor#run()} method using
051         * {@link IZBotScriptLauncher#setTestcaseBatchExecution(TestcaseBatchExecution)} method before actually
052         * starting the batch execution.
053         * <br/>
054         * <b>See Also</b> {@link #batchStart()}
055         */
056        public void batchStart() ;
057
058        /**
059         * This method is invoked once before start of each testcase.
060         * <br/>
061         * The {@link ScriptProcessor#run()} method loops through each of the testcases within a batch
062         * and calls {@link IZBotScriptLauncher#testcaseExecutionStart()} method just before starting the
063         * testcase execution.
064         * <br/>
065         * <b>See Also</b> {@link #testcaseExecutionStart()}
066         */
067        public void testcaseExecutionStart() ;
068
069        /**
070         * This method actually executes the testcase.
071         * Custom implementations of this method should not throw exceptions.
072         * Exceptions must be caught and appropriately dealt with.
073         * <br/>
074         * The {@link ScriptProcessor#run()} method loops through each of the testcases within a batch
075         * and calls {@link IZBotScriptLauncher#testcaseExecutionRun()} method to execute the testcase,
076         * immediately after calling {@link IZBotScriptLauncher#testcaseExecutionStart()} method.
077         * <br/>
078         * <b>See Also</b> {@link #testcaseExecutionRun()}
079         */
080        public void testcaseExecutionRun() ;
081
082        /**
083         * Use this method to process testcase result.
084         * <br/>
085         * After the testcase{s} has been executed, the result{s} are processed within
086         * {@link ScriptProcessor#run()} method by calling {@link IZBotScriptLauncher#testcaseExecutionResult()}
087         * method.
088         * <br/>
089         * <b>See Also</b> {@link #testcaseExecutionResult()}
090         */
091        public void testcaseExecutionResult() ;
092
093        /**
094         * This method is invoked once after each testcase is done executing.
095         * If there is any cleanup task that need to be performed after each testcase,
096         * this is ideal place to do it.
097         * <br/>
098         * The {@link ScriptProcessor#run()} method by calls{@link IZBotScriptLauncher#testcaseExecutionEnd()}
099         * method.
100         * <br/>
101         * <b>See Also</b> {@link #testcaseExecutionEnd()}
102         */
103        public void testcaseExecutionEnd() ;
104
105        /**
106         * Launcher must keep updated the status of testcase at all times.
107         * E.g. "batch started", "tc#5 executed", "batch ended", etc.
108         * This status is updated in Agent.
109         */
110        public String getAgentStatus() ;
111
112        /**
113         * This method is invoked once after end of batch. Any batch cleanup activities
114         * can be performed in this method.
115         * <br/>
116         * Once all the testcases within a batch have been executed,the {@link ScriptProcessor#run()} method
117         * calls the {@link IZBotScriptLauncher#batchEnd()} method.
118         * <br/>
119         * <b>See Also</b> {@link #batchEnd()}
120         */
121        public void batchEnd() ;
122
123        /**
124         * Enable real-time result update.
125         * @return boolean
126         * <br/>
127         * Once the script has been executed, {@link ScriptProcessor#run()} method updates the Zbot agent
128         * real-time status using {@link IZBotScriptLauncher#enableResultUpdate()} method and communicates
129         * this update back to the Zephyr server.
130         * <br/>
131         * <b>See Also</b> {@link #enableResultUpdate()}
132         */
133        public boolean enableResultUpdate();
134
135        /*----------------------------------------------------------
136         * END OF LIFE CYCLE METHODS
137         *----------------------------------------------------------*/
138
139        /*----------------------------------------------------------
140         * GETTER/SETTER METHODS
141         *----------------------------------------------------------*/
142
143        /**
144         * getter for Agent
145         */
146        public Agent getAgent() ;
147
148        /**
149         * setter for Agent.
150         * <br/>
151         * Before starting the batch execution of testcases, the {@link ScriptProcessor#run()} method sets
152         * the Agent using {@link IZBotScriptLauncher#setAgent(Agent)} method.
153         */
154        public void setAgent(Agent agent) ;
155
156        /**
157         * getter for URL
158         */
159        public String getUrl() ;
160
161        /**
162         * setter for URL.
163         * <br/>
164         * Before starting the batch execution of testcases, the {@link ScriptProcessor#run()} method sets
165         * the 'url' which is a string object using {@link IZBotScriptLauncher#setUrl(String)} method.
166         */
167        public void setUrl(String url) ;
168
169        /**
170         * @return the zbotProperties
171         */
172        public PropertiesConfiguration getZbotProperties();
173
174
175        /**
176         * Other misc properties that are read from zbot.properties file, are pushed into this hashmap.
177         * @param zbotProperties the zbotProperties to set
178         */
179        public void setZbotProperties(PropertiesConfiguration zbotProperties);
180
181        /**
182         * utility method to get TestcaseBatchExecution
183         */
184        public TestcaseBatchExecution getTestcaseBatchExecution();
185
186        /**
187         * utility method to set TestcaseBatchExecution.
188         * <br/>
189         * The TestcaseBatchExecution object is set in the {@link ScriptProcessor#run()} method using
190         * {@link IZBotScriptLauncher#setTestcaseBatchExecution(TestcaseBatchExecution)} method before
191         * starting the batch execution.
192         *
193         */
194        public void setTestcaseBatchExecution(TestcaseBatchExecution testcaseBatchExecution) ;
195
196        /**
197         * utility method to get Current TestcaseExecution
198         */
199        public TestcaseExecution getCurrentTestcaseExecution() ;
200
201        /**
202         * utility method to set Current TestcaseExecution.
203         * <br/>
204         * Every time the {@link ScriptProcessor#run()} method loops through each of the testcases
205         * within a batch, it sets the current testcase using
206         * {@link IZBotScriptLauncher#setCurrentTestcaseExecution(TestcaseExecution)} method.
207         */
208        public void setCurrentTestcaseExecution(TestcaseExecution currentTestcaseExecution) ;
209
210        /*----------------------------------------------------------
211         * END OF GETTER/SETTER METHODS
212         *----------------------------------------------------------*/
213
214    public void testcaseParseExecutionResult() ;
215
216
217}