Scheduling a Test Suite

One of the main benefits of creating a Test Suite is that it can be scheduled to run one or more times at pre-defined intervals. Examine makes use of the fantastic Quartz open-source scheduler to schedule jobs and run them at the user-set time intervals. There are two types of schedules that can be created for each Test Suite:

To create a new schedule switch to the Schedules tab and click on the Add New Schedule link. The Schedules tab displays all the schedules created for this Test Suite in a table as shown below:

Figure 7.4. Test Suite Schedule Configuration

Test Suite Schedule Configuration


When a test schedule is running, clicking on the Refresh button reloads the available result data for the schedule until that point and updates the execution state of the schedule.

The Auto Refresh checkbox when checked automatically refreshes the schedule state and the execution result data every 2 seconds.

A running schedule can be paused and resumed during the Pause and Resume buttons. A paused schedule will stop any more executions of the Test Suite until it is resumed again.

Test Suite Execution States

Test Suite schedules can be the following execution states at any given time:

PENDING ()

Initial state that all schedules start with. Schedules remain in this state until they have started based on their start date/time

RUNNING ()

The state that the schedule is in when it is currently running the test cases that are part of the test suite to which this schedule belongs.

COMPLETED ()

The final state that the schedule transitions to after it is has completed all the required runs (based on the repeat count if it was set). For e.g. if the schedule is created to repeat 3 times. Then it will transition to COMPLETED state after 4 successful runs.

PAUSED ()

When a schedule is currently running, it can be paused to stop any more execution of the test cases that are part of the test suite to which this schedule belongs. The schedule remains in this state until it is resumed, in which case it transitions to the RUNNING state. Note that pausing schedules in PENDING and COMPLETED state does not affect the state.

Simple schedule

A Simple Schedule, as the name implies is the simplest and quickest way to create a Test Suite schedule. The Simple Schedule is based on the Quartz SimpleTrigger functionality. The options for this type of schedule are as shown below:

Figure 7.5. Test Suite Simple schedule dialog

Test Suite Simple schedule dialog


Name

This is a required field that should specify a unique logical name for the Test Suite schedule.

Start Date

Click on the Select link button to open the calendar dialog to select the date and time that this schedule should start its first run. If it is not selected, the start date defaults to "now" i.e. the schedule will take effect immediately

End Date

Click on the Select link button to open the calendar dialog to choose the date/time when this schedule will stop execution. The end time if specified overrides the repeat count value. This is useful if you don't care about the number of exact times the test suite executes and ould like to see it run until a specific end time at a specific repeat interval (if specified).

Repeat Count

Specifies the number of additional times that this test suite will execute. By default this value is 0, which means that the test suite executes only once. For e.g. if the value is 3, then there will 4 total runs.

Interval (secs)

Specifies the time interval between the job repetitions. For e.g. if the inteval is specified as 5, then the test suite executes every 5 seconds until the repeat count +1 iterations or until the end time.

Cron-based schedule

A cron-based schedule is an alternate way to schedule Test Suites. It makes use of a "cron" expression to specify the frequency and time-constraints of the execution of the Test Suite.

Tip

"cron" is an unix program that is used to schedule jobs (command and shell scripts) to run periodically at certain dates and times. It is generally used to automate some administration tasks like backing up data or checking email etc.

The cron-based scheduling feature of Examine leverages the powerful cron-like functionality provided by the Quartz scheduler. Quartz provides a CronTrigger that is used by Examine to schedule Test Suite executions.

The options for this type of schedule are as shown below:

Figure 7.6. Test Suite Cron-based schedule dialog

Test Suite Cron-based schedule dialog


Name

This is a required field that should specify a unique logical name for the Test Suite schedule.

Start Date

Click on the Select link button to open the calendar dialog to select the date and time that this schedule should start its first run. If it is not selected, the start date defaults to "now" i.e. the schedule will take effect immediately

End Date

Click on the Select link button to open the calendar dialog to choose the date/time when this schedule will stop execution.

Cron Expression

Specify a valid cron-expression that indicates how frequently this job should execute.

Cron-Expressions are strings that are actually made up of seven sub-expressions, that describe individual details of the schedule. These sub-expression are separated with white-space, and represent:

  • Seconds

  • Minutes

  • Hours

  • Day-of-Month

  • Month

  • Day-of-Week

  • Year (optional field)

An example of a complete cron-expression is the string "0 0 12 ? * WED" - which means "every Wednesday at 12:00:00 pm".

For a detailed explanation of how to specify the cron-expression, please refer to the excellent Quartz documentation on this topic:

http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/tutorial-lesson-06

http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger