⇐ Orkney Builtin-Steps
Navigation

Orkney Step Development

Orkney Logo

Contents

Introduction

Orkney comes with some useful test classes also called test step. For your own test objects you may need to create your own test steps. This part of the Orkney documentation will explain how to do that.

Your first step

Lets create a test step sending a HTTP request to a web server and read the response. The test step parameters shall be

Name
Direction
Type
Description
protocol
input
String
Specifies the protocol to use and must be one of http / https. Optional, will be defaulted to http.
host
input
String
The web server host name or IP address.
port
input
int
The web server port number.
uri
input
String
The uri part of the web address.
request
input
String The request to be send.
status
output
int
The HTTP status code received.
response
output
String
The response recieved.

A test step is a class implementig the Orkney TestStep interface. This interface is given below

package de.softquadrat.orkney.api;

/**
 * Instances of this interface are used inside a test case to implement a test step.
 */
public interface TestStep {
  /**
   * Set up this test case using the context given.
   @param context the test context used during execution.
   @throws Exception in case if any errors during set up.
   */
  public void setUp(TestStepContext contextthrows Exception;

  /**
   * Runs the test step.
   @throws Exception in case of execution errors (test failed).
   */
  public void runTest() throws Exception;

  /**
   * Tear down the test step-
   @throws Exception in case if any errors during tear down.
   */
  public void tearDown() throws Exception;

  /**
   * Gets all input parameters of the test step.
   @return all input parameters.
   */
  public TestParameterType[] getInParameterTypes();

  /**
   * Gets all output parameters of the test step.
   @return all output parameters.
   */
  public TestParameterType[] getOutParameterTypes();

  /**
   * Gets the description of the test step.
   @return the description of the test step.
   */
  public String getDescription();
}

A test step must implement three test methods that will be called for test set up, test execution and test tear down

Other methods are used to define the parameters and give the description of the test step

We create our first implementation starting with the parameter and description methods. First of all we define the class with some String constants.

public class CallWebserver implements TestStep {
  private static final String UTF_8 = "UTF-8";
  private static final String PROTOCOL = "protocol";
  private static final String HOST = "host";
  private static final String PORT = "port";
  private static final String URI = "uri";
  private static final String REQUEST = "request";
  private static final String STATUS = "status";
  private static final String RESPONSE = "response";
  ...
}

xxx

public class CallWebserver implements TestStep {
  private static final String UTF_8 = "UTF-8";
  private static final String PROTOCOL = "protocol";
  private static final String HOST = "host";
  private static final String PORT = "port";
  private static final String URI = "uri";
  private static final String REQUEST = "request";
  private static final String STATUS = "status";
  private static final String RESPONSE = "response";
  private static final TestParameterType[] IN_PARAMETER = {
    new TestParameterType(PROTOCOL, String.class, "Specifies the protocol to use and must be one of http / https. Optional, will be defaulted to http."),
    new TestParameterType(HOST, String.class, "The web server host name or IP address."),
    new TestParameterType(PORT, Integer.class, "The web server port number."),
    new TestParameterType(URI, String.class, "The uri part of the web address."),
    new TestParameterType(REQUEST, String.class, "The request to be send."),
  };
  private static final TestParameterType[] OUT_PARAMETER = {
    new TestParameterType(STATUS, Integer.class, "The HTTP status code received."),
    new TestParameterType(RESPONSE, String.class, "The response recieved."),
  };

  @Override
  public TestParameterType[] getInParameterTypes() {
    return IN_PARAMETER;
  }

  @Override
  public TestParameterType[] getOutParameterTypes() {
    return OUT_PARAMETER;
  }

  @Override
  public String getDescription() {
    return "Test step calling a web server.";
  }
  ...
}



public class CallWebserver implements TestStep {
  private static final String UTF_8 = "UTF-8";
  private static final String PROTOCOL = "protocol";
  private static final String HOST = "host";
  private static final String PORT = "port";
  private static final String URI = "uri";
  private static final String REQUEST = "request";
  private static final String STATUS = "status";
  private static final String RESPONSE = "response";
  private static final TestParameterType[] IN_PARAMETER = {
    new TestParameterType(PROTOCOL, String.class, "Specifies the protocol to use and must be one of http / https. Optional, will be defaulted to http."),
    new TestParameterType(HOST, String.class, "The web server host name or IP address."),
    new TestParameterType(PORT, Integer.class, "The web server port number."),
    new TestParameterType(URI, String.class, "The uri part of the web address."),
    new TestParameterType(REQUEST, String.class, "The request to be send."),
  };
  private static final TestParameterType[] OUT_PARAMETER = {
    new TestParameterType(STATUS, Integer.class, "The HTTP status code received."),
    new TestParameterType(RESPONSE, String.class, "The response recieved."),
  };

  @Override
  public TestParameterType[] getInParameterTypes() {
    return IN_PARAMETER;
  }

  @Override
  public TestParameterType[] getOutParameterTypes() {
    return OUT_PARAMETER;
  }

  @Override
  public String getDescription() {
    return "Test step calling a web server.";
  }
  ...
}

The Orkney API

Java Doc can be found here.

Generating Step Documentation

GenerateDoc

⇐ Orkney Builtin-Steps Navigation