Skip to content
QiTASC.com / Data Steps and Compound Steps /
Download Data Compound Steps
/ .. /
Download Data Compound Steps





Download Data Compound Steps

The following Compound Steps are used for downloading data to a phone's memory phone's memory using WiFi or a mobile data connection.

Note:

  • Before downloading any data, the phone(s) must be connected to the internet via a WiFi or mobile data network.

  • Steps where the download should successfully finish, in other words the download is not interrupted, need an Expectation Step to confirm the phone enters the expected state within the timeout.

  • Certain Step Details are incompatible with each other. If Incompatible Step Details are used, an exception will be printed to the log.

  • The colon (:) written after the starts downloading Step must be added in order to use Step Details.

Start a Download

This Step starts the download. The Expect the Download to Finish Step should be used with this Step.

Syntax

1
<name Identifier> starts a download from <url String> as <downloadName Identifier>:

Parameters

  • name - The name assigned to the phone

  • downloadName - The name assigned to the download, allowing it to be referenced later in the test case

Example

1
And A starts a download from "http://www.google.com" as MYDOWNLOAD:

Stop a Download

This Step Detail stops the download after one of:

  • A given amount of time, specified as time duration.

  • A defined amount of data has been downloaded, specified in number of volume bytes.

The Expect the Download to Finish Step should be used with this Step Detail.

Note: If neither the time limit details clause nor the volume limit clause are given, a default of a 30-second time limit is used.

Stop a Download: Given Amount of Time

This Step Detail stops a download after a specified amount of time.

Syntax

1
* it stops after <time Number> <timeUnit TimeUnit>

Parameters

  • time - The number of timeUnits

  • timeUnit - One of second, seconds, minute or minutes

Example

1
2
3
4
5
6
7
A starts a download from "http://testdata.qvie.qitasc.com/data/100MB" as MYDOWNLOAD:
    * it stops after 2 minutes

And within 180 seconds, A expects download MYDOWNLOAD to finish

# Verification of the specified download time duration
And verify MYDOWNLOAD.durationMinutes == 2

Stop a Download: Given Amount of Volume

This Step Detail stops a download after a specified amount of data.

The Expect the Download to Finish Step should be used with this Step Detail.

Syntax

1
  * it stops after <volume Number> <dataUnits dataUnit>

Parameters

  • volume - The number of specified volume units

  • dataUnits - One of bytes, kB, MB, GB, KiB, MiB or GiB

Example

1
2
3
4
5
6
7
8
9
A starts a download from "http://testdata.qvie.qitasc.com/data/100MB" as MYDOWNLOAD:
    * it stops after 10 MB

And within 180 seconds, A expects download MYDOWNLOAD to finish


# Verification of the scheduled amount of the downloaded bytes and volume units
And verify MYDONWLOAD.dataVolumeAmount == 10000000
And verify MYDOWNLOAD.dataVolumeUnit == "bytes"

Stop a Download: Given Amount of Data or Time

In addition to stopping a download after either a time limit or data volume limit has been reached, both clauses can be used together to stop a download. Whichever limit is reached first will define when the download is stopped.

The Expect the Download to Finish Step should be used with these Step Details.

Example

1
2
3
4
5
And A starts a download from "http://testdata.qvie.qitasc.com/data/10MB" as MYDOWNLOAD:
    *  it stops after 10MB
    *  it stops after 10 seconds

And within 180 seconds, A expects download MYDOWNLOAD to finish

In the example above, the download will stop once either 10 seconds have passed or 10 MB have been downloaded.

Note: The download will stop when one condition evaluates to true, regardless of which one is reached first.

Allow/Disallow Reconnects

This Step Detail can be used to either allow or disallow reconnects after periods of inactivity.

Disallow Reconnects

Instead of reconnecting, the download is treated as failed.

Syntax/Example

1
  * it disallows reconnects

Allow Reconnects

This Step allows for a maximum amount of reconnects. If that number is exceeded, the download is considered failed. If the number of reconnects is not set, an unlimited number of reconnects is allowed.

Syntax

1
  * it allows <number Number> reconnects

Parameter

  • number - The number of allowed reconnects
    • This number is a literal value in a Feature File or a Context Object that is shared among multiple Feature Files
    • For configuration information, see the Data Traffic Configuration section

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Given a phone as A:
    *  of type Android

And deferred, within 30 seconds, A disables data connections
And within 30 seconds, A enables data connections
And A starts a download from "http://testdata.qvie.qitasc.com/data/10MB" as MYDOWNLOAD:
    *  it stops after 10 MB
    *  it allows 7 reconnects

And wait for 10 seconds
And within 30 seconds, A expects download MYDOWNLOAD to finish

# Verification of the predefined amount of allowed reconnects
And verify MYDOWNLOAD.reconnects == 7

Reconnects after Inactivity

Reconnects when no packets are received within the timeout.

The Expect the Download to Finish Step should be used with this Step Detail.

Syntax

1
  * it reconnects when detecting <time Number> <timeUnit TimeUnit> of inactivity

Parameters

  • time - The number of timeUnits

  • timeUnit - One of second, seconds, minute or minutes

Example

1
2
3
4
5
A starts a download from "http://testdata.qvie.qitasc.com/data/100MB" as MYDOWNLOAD:
    *  it allows 7 reconnects
    *  it reconnects when detecting 20 seconds of inactivity

And within 180 seconds, A expects download MYDOWNLOAD to finish

Interrupt a Download

This Step immediately interrupts a download. Interrupted downloads do not return a download result or produce a speed profile chart.

Syntax

1
<name Identifier> interrupts the download <downloadName String>

Parameters

  • name - The name assigned to the phone

  • downloadName - The name assigned to the download

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Given a phone as A:
    *  of type Android

And deferred, within 30 seconds, A disables data connections
And within 30 seconds, A enables data connections

And A starts a download from "http://testdata.qvie.qitasc.com/data/400MB" as MYDOWNLOAD:
    *  it stops after 100 seconds

And wait for 5 seconds
And A interrupts the download MYDOWNLOAD

Retrieve Download Step Information

Information regarding download Steps are made available to the result Context Object when using the <phone Identifier> starts a download from <url Url> as <download Identifier>:. There are two ways to access this information:

  • Using getExecutionContextObject("<download Identifier>")["result"] from UI Steps or Steps.

  • Using <download Identifier>.result from Verification Steps. For example, MYDOWNLOAD.result.summary.

The following are returned depending on the object structure:

  • startTimeInMillis (starting time) - Number

  • speedProfile (speed measurement intervals) - A list of intervals

  • summary - A single instance of interval

Intervals describe a number of bytes (nrOfBytes) that have been downloaded in a given amount of milliseconds (nrOfMilliSeconds).

Custom Language Syntax

1
2
3
4
5
6
// Speed measurement intervals
<speedProfile Object> := getExecutionContextObject("<download Identifier>")["result"].speedProfile
// Starting Time
<startTimeInMillis Object> := getExecutionContextObject("<download Identifier>")["result"].startTimeInMillis
// Summary
<summary Object> := getExecutionContextObject("<download Identifier>")["result"].summary

Speed Profile Stepdef Example

1
2
3
4
5
6
7
8
9
stepdef "print speed profile for {downloadId}" /downloadId/
    speedprofile := getExecutionContextObject(downloadId)["result"].speedProfile
    i := 0
    for segment in speedprofile
        avgSpeed := (segment.nrOfBytes / segment.nrOfMilliSeconds * 8 * 1000 / 1024 / 1024)
        println(i + ": " + avgSpeed.toString() + " Mbit/s")
        i := i + 1
    end
end

Starting Time Stepdef Example

1
2
3
4
stepdef "print starting timestamp for {downloadId}"/downloadId/
    starttime := getExecutionContextObject(downloadId)["result"].startTimeInMillis
    println("starttime: "+starttime)
end

Summary Stepdef Example

1
2
3
4
5
6
7
8
9
stepdef "print average speed for {}" / downloadId/
    summary := getExecutionContextObject(downloadId)["result"].summary
    // Calculating Mbits/s
    avgSpeed := (summary.nrOfBytes / summary.nrOfMilliSeconds * 8 * 1000 / 1024 / 1024)

    println("####################################")
    println("Avg speed in Mbits/s is:" + avgSpeed.toString())
    println("####################################")
end

Speed Profile Chart

A speed profile chart will be generated when executing the expect download to finish Step in a Feature File. The speed chart for the above example would look as follows:

alt text

Test Case Example

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Feature: DownloadMetaStepContext
  Scenario: DownloadMetaStep Context

    Given a phone as A:
     * of type Android

    And deferred, within 30 seconds, A disables data connections
    And within 30 seconds, A enables data connections

    And A starts a download from "http://testdata.qvie.qitasc.com/data/10MB" as MYDOWNLOAD:
     * it stops after 10 MB
    # This sets the parameter dataVolumeAmount to the specified value or -1 if unspecified.

    And wait for 10 seconds
    And within 30 seconds, A expects download MYDOWNLOAD to finish
    # After the download has finished, its result summary object can be accessed.

    And verify MYDOWNLOAD["result"].summary.nrOfBytes == MYDOWNLOAD.dataVolumeAmount

The example above verifies that the actual amount of bytes downloaded and the expected amount of bytes downloaded are equal.