/
.Net Runner

.Net Runner

Introduction

This page describes how to execute a specification using the command line interface that comes with GreenPepper.

Features

 GreenPepper provides a command line interface to execute specifications captured in HTML files. The command line interface has the following features:

  • Execution of a single specification file
  • Execution of a suite of specifications stored in a directory tree

Running the command line application

Running  GreenPepper requires FrameWork 2.0 (source are fully compatible with FrameWork 1.1)

The following assemblies are required on the classpath option in your command line :

  • your fixture code
  • your system under test
  • all the external assemblies your system under test depends upon

An Example

Let's assume that our application is packaged in the system-under-test.dll assembly, our fixture code is packaged in the fixtures.dll assembly and our application depends on the external-dependency.dll assembly.

GreenPepper.exe -a fixtures.dll;system-under-test.dll;external-dependency.dll <arguments>

Arguments

Invoking the command line interface with the --help option brings up the usual help message:

Usage: GreenPepper [options] input [ouput]
Run the input specification and produce a report in output file or in directory specified by -o

Options:
-f, --sud CLASS;ARGS          Use CLASS as the system under development and instantiate it with ARGS
-o DIRECTORY                  Produce reports in DIRECTORY (defaults to current directory)
-r CLASS;ARGS                 Use CLASS as the document repository and instantiate it with ARGS (defaults to Greenpepper.Repositories.FileSystemRepository)
-s, --suite                   Run a suite rather than a single test (output must refer to a directory)
-t SECTIONS                   Filter input specification to only execute SECTIONS (comma separated list of sections)
    --xml                     Generate XML report (defaults to plain)
    --help                    Display this help and exit
    --version                 Output version information and exit
-a ARGS                       Semicolon seperated list of assemblies fullName
    --lazy                    Set greenpepper in lazy mode for document execution
-l, --locale LANG             Set application language (en, fr, ...)
    --debug                   Enable debug mode
    --selector CLASS          Use CLASS as the interpreter selector (defaults to Greenpepper.Documents.GreenPepperInterpreterSelector)
    --stop                    Stop the execution of the specification on the first failure
-e, --encoding NAME           Set file encoding
-c, --appconfig FILE          Set the application configuration file to use (app.config)

Default options

When no option is given,  GreenPepper defaults to the following rules:

  • Input is a single specification, not a suite
  • If output is not specified, reports are produced in the current directory
  • Report is in plain format
  • The operating system locale is used
  • The input specification is not filtered
  • The specification file must be located on the file system
  • Fixtures are created using the default built-in mechanism
  • Tables use  GreenPepper formalism
  • Lazy mode is disabled
  • Debug mode is disabled
  • Locale is set to default machine locale
  • Will not stop the execution on first failure

Any of the rules above can be overridden using command line switches.

Running with the default options

By default  GreenPepper executes the specification file given as an input and produces a report in the current directory. The name of the report is constructed from the name of the specification.

The specification file has to be an HTML file (with the .html extension) accessible on the file system.  GreenPepper will execute the specification and produce both:

  • an execution summary displayed in the terminal window
  • a report file, which contains the executed specification annotated with test results

Here's an example:

Running with default options

Executing the command:

GreenPepper.exe -a ... example.html

might display the following in the terminal window:

Running example.html
14 example(s): 9 right, 3 wrong, 1 ignored, 1 exception(s) <<< FAILURE!

Specifying an output directory -o

The destination directory for report files can be specified using the -o option.

Alternatively, the output argument can be used to specify the absolute path of the report file.

Specifying an output directory

Executing the command:

GreenPepper.exe -a ... -o reports example.html

might display the following in the terminal window:

Running example.html
14 test(s): 9 right, 3 wrong, 1 ignored, 1 exception(s)

and produce a report file named example.html in the reports directory.

Executing a set of specification files (-s, --suite)

 GreenPepper can execute all specification files found in a given directory (recursively) and produce result files in the specified output directory. The suite mode is activated using the -s option.

If the output directory does not exist,  GreenPepper will try to create it. Input files need to be in HTML form and have the.html extension.

Running a suite of specifications

To execute all specification files found in the /home/myuser/workspace/myprojects/specs directory and produce output in the /home/myuser/workspace/myprojects/reports directory, use the following command from the/home/myuser/workspace/myprojects directory:

GreenPepper.exe -a ... -s -o reports specs

If the specs directory looks like this:

home
  |____ myuser
           |____ workspace
                     |____ myproject
                               |____ specs
                                       |____ Authentication
                                       |           |____ Login.html
                                       |____ Authorization
                                                   |____ AccessControl.html         

The reports directory would then contain the following files:

home
  |____ myuser
           |____ workspace
                     |____ myproject
                               |____ reports
                                       |____ Authentication.Login_html.html
                                       |____ Authorization.AccessControl_html.html

Filtering out parts of the specification (-t)

When the specification file contains sections identified by tags, it is possible to execute only those parts of the specification that are relevant using the -t option. The -t switch has to be followed by a comma separated list of tags to consider for execution.

Filtering the specification

We can execute only the sections of the specification marked with the authentication and authorization tags like this:

GreenPepper.exe -a ... -t authentication,authorization example.html result.html

Producing XML reports (--xml)

It is possible to produce the report file in XML format using the --xml option. The XML format produces an output file that contains both execution statistics and the annotated HTML specification.

Producing XML reports

GreenPepper.exe -a ... --xml example.html result.html

Using a custom specification repository (-r)

The default is for  GreenPepper to look for specifications on the file system. When you want to use a different specification repository, use the -r option followed by the fully qualified class name of the Repository class and a semi-colon separated list of constructor parameters for that class.

Changing the specification repository

To use the FileSystemRepository issue the command:

GreenPepper.exe -a ... -r Geenpepper.Repositories.FileSystemRepository example.html result.html

Specifying a custom system under development (--sud)

 GreenPepper will use the DefaultSystemUnderDevelopment unless told otherwise. To specify a different system under development class, use the --sud option followed by the fully qualified class name and a semi-colon separated list of constructor parameters for that class.

Changing the system under development

GreenPepper.exe -a ... --sud MyNameSpace.MySystemUnderDevelopment;arg1;arg2 example.html result.html
 

Changing table formalism (e.g. for Fit compliance)

It is possible to change  GreenPepper table formalism by specifying an InterpreterSelector class with the --selector option. By default  GreenPepper will use its own formalism.

Enabling Fit compliance mode

As an example, to enable Fit compliance, use the class Greenpepper.Fit.FitInterpreterSelector available in the Extensions.Fit assembly. This will cause  GreenPepper to use Fit formalism for tables and support Fit basic interpreters:

Our fit compliance is using Fit assembly version 1.1

 

For more informations about Fit compliance see Fit Compliance 
GreenPepper.exe -a GreenPepper.Extensions.FIT.dll;... --selector Greenpepper.Fit.FitInterpreterSelector example.html result.html

Setting lazy mode (--lazy)

Enabling lazy mode changes  GreenPepper behaviour :

  • Lazy mode : On a greenpepperized document, all tables that are contained in documents will be skipped until you specify a [greenpepper-example] macro for the table or group of tables you want to be not skipped.
  • Not lazy mode (default) : this mode is an Eager mode, it means that all tables will be interpreted.

Enabling lazy mode

To enable lazy mode, use the command:

GreenPepper.exe -a ... --lazy

Setting debug mode (--debug)

Enabling debug mode allows you to have a full view of exceptions stack trace in your  GreenPepper specifications documents. Note that in the normal mode the stack trace are limited.

Enabling debug mode

To enable debug mode, use the command:

GreenPepper.exe -a ... --debug 
 

Changing locale (-l, --locale)

By default  GreenPepper uses hosting machine locale.

Changing the locale changes the way of  GreenPepper interpret specific culuture.
For example, with en-US locale, dates will we interpreted and parsed as US dates.

Locale values are all standard .NET locales here is a list of supported locales

Changing default locale

 GreenPepper.exe -a ... -l en-US

Stop on first failure (--stop)

Stop on first failure

To stop the execution of a specification when a failure is detected, use the command:

 java -cp ... com.greenpepper.runner.Main --stop
 

Note : Only the current specification execution will be stopped, the suite will continue for the remaining specifications

Using an app.config (-c or --appconfig) - (NEW in 2.7)

App.config

To use a custom app.config, specify the parameter c or -appconfig followed by the location of the configuration file.

 java -cp ... com.greenpepper.runner.Main -c /myproject/bin/debug/myapp.config