Skip to content

Latest commit

 

History

History
287 lines (214 loc) · 6.15 KB

TESTS.adoc

File metadata and controls

287 lines (214 loc) · 6.15 KB

Steeltoe Sample Application Tests

Pre-Requisites

Running the Samples tests requires Python 3.

A convenience script is provided to setup a Python 3 environment for the tests. The script assumes Python 3 and its associated package installer, pip, have been installed.

The following sections detail how to install Python 3 and pip for supoorted platforms.

Windows

Install choco if needed.

Start a PowerShell as Administrator, run:
PS C:\WINDOWS\system32> choco install -y python3
PS C:\WINDOWS\system32> refreshenv
PS C:\WINDOWS\system32> pip install virtualenv

OS X

Install brew if needed.

In a terminal, run:
$ brew install python3
$ pip3 install virtualenv

Ubuntu

In a terminal, run:
$ sudo apt install python3 python3-pip
$ sudo pip3 install virtualenv

Setup

Test Environment

Change to the root directory of the Sample repo.

Windows
C:> test-setup
Posix
$ ./test-setup

user.ini

Create a user.ini file in the roject root directory. An example file, user.ini.example, is provided as a convenience.

Windows
C:> copy user.ini.example user.ini
Posix
$ cp user.ini.example user.ini

The example file’s options are commented with descriptions.

The one option you probably want to enable is windowed = yes. Setting this option will run backgrounded processes in their own dedicated windows, making it easier to follow a test’s progress.

CloudFoundry

Credentials and Bootstrap Space

If you don’t specify credentials, it is assumed you are already logged in to a CloudFoundry endpoint. The current target will be used to create additional spaces for running tests.

You can configure the tests to use their own credentials by setting the following options in user.ini:

  • cf_apiurl

  • cf_username

  • cf_password

  • cf_org

Set cf_domain if the target CloudFoundry domain has been changed from its default.

It is expected that a CloudFoundry space named development exists for the configured credentials. The development space will be used as the target from which to create additional spaces for running tests.

Example: CloudFoundry credentials in user.ini
[behave.userdata]
cf_apiurl = api.run.pez.pivotal.io
cf_username = myuser
cf_password = mypass
cf_org = p-steeltoe
cf_domain = cfapps.pez.pivotal.io

Run

Change to the root directory of the Sample repo.

Windows
C:> test-run ...
Posix
$ ./test-run ...

The test-run script is wrapper that loads the local Python envionment and then runs behave. Any arguments passed to test-run are passed on to behave. Available arguments can be see by running test-run -h or viewing online documentation.

Examples

Example: Run all tests
C:> test-run
Example: Run tests for simple CloudFoundry configuration
C:> test-run Configuration/src/AspDotNetCore/CloudFoundry

Tags

Tags can be used to specify a subset of tests to run. Tags are specified using -t or --tags.

  • Framework Tags

    • netcoreapp2.0

    • net461

  • Runtime Tags

    • win-10-x64

    • ubuntu.14.04-x64

  • Runtime Environment Tags

    • cloud

    • local

Example: Run tests for .NET Core App 2.0 framework targeting the Ubuntu runtime
C:> test-run -t netcoreapp2.0 -t ubuntu.14.04-x64
Example: Run tests that run locally
C:> test-run -t local

Tracker Tags

If a tracker issue is associated with a test, that test will be tagged with the issue number.

Example: run the test or tests associated with the tracker issue 152883475
C:> test-run -t #152883475

Options

Option defaults are defined in behave.ini.

Options can be specified using command line arguments or the file user.ini.

Command line options take precedent over those defined in user.ini.

To set a boolean option to true, specify a value equal to one of 1, yes, true, on.

To set a boolean option to false, specify a value equal to one of 0, no, false, off.

Command Line Options

Command line arguments take the form of: -Dname[=value]

Specifying a command line option with no value results in a value of true regardless of the option type.

Example: set an option using a command line switch
C:> test-run -Dfoo=bar

Available Options

Option

Type

Default

Descritpion

cf_api_url

string

CloudFoundry API endpoint

cf_domain

string

CloudFoundry domain; if not set, domain derived from the API endpoint

cf_max_attempts

integer

120

how may attempts to determine if a CloudFoundry service or app is available; specify a negative value to try ad infinitum

cf_org

string

CloudFoundry org

cf_password

string

CloudFoundry password

cf_space

string

CloudFoundry space to be used for tests; if not set, a random unique name is generated for each test

cf_username

string

CloudFoundry username

cleanup

boolean

true

if true, test artifacts (such as CloudFoundry spaces) are torn down upon test completion

debug_on_error

boolean

false

if true, enter debugger upon test failure

output

string

test.out

directory into which output is written; useful on Windows to circumvent file too long errors

max_attempts

integer

30

how may attempts to determine if a local service or app is available; specify a negative value to try ad infinitum

windowed

boolean

false

if true, run background processes in their own window