Robot Framework HTTP Server Library

Java version 8 based Robot Framework library for HTTP client application testing. Provides HTTP server which can be configured with mock responses. It also saves content from all the requests for further inspection and testing. Library is build upon Jetty HTTP server project

The idea for this came same time with the JMS library. There was a need to simulate applications publishing their services with SOA and REST APIs. I chose Java and Jetty because I was already very familiar with them and JMS library was also chosen as Java based library. This project also taught me new ways to overload robot keywords with Java project.

Check Robot keyword documentation from libdoc. Project sources are available from GitLab.

Maven dependency:

<dependency>
   <groupId>net.relaysoft.robotframework</groupId>
   <artifactId>http-server-library</artifactId>
   <version>1.0.0</version>
</dependency>

Simple example how HTTP server library can be used.

*** Settings ***
Library HTTPServer

*** Variables ***
${PORT} ${8280}
${CONTENT} Test content
${CONTENT_TYPE} text/plain
&amp;{HEADERS} header1=value1 header2=value2

*** Test Cases ***
Test Request
Initialize HTTP Server ${PORT}
Start HTTP Server
Set Default Response content=${CONTENT} statusCode=${200} contentType=${CONTENT_TYPE} headers=&amp;{HEADERS}
# Make application or library to execute request against mock server
${request} = Get HTTP Request
${content} = ${request.body}
# Do something with the content...

It is also possible the let library choose an free open port for the mock HTTP server by giving port value of 0 when executing keyword ‘Initialize HTTP Server‘. In this case you can get selected port afterwards with the keyword ‘Get HTTP Server Port‘.

If needed this library can also be used as remote library by using jrobotremoteserver project.