Popular searches
//

MongoDB for the robot

6.6.2013 | 2 minutes reading time

We use the Robot Framework for some time for automated software tests in our projects. In addition, a few of my colleagues deal with the NoSql Database MongoDB (Tutorial MongoDB ). The document management solution Center-Device (Start-Up of Codecentric AG) also uses MongoDB in the backend (Center-Device Architecture-Overview ). So I thought, it’s time for a new Robot-Library: robotframework-mongodblibrary . The version 0.2.1 is ready for download on GitHub (Keyword-Documentation ).

The library is written in Java (Jython) and uses internally the MongoDB Java Driver. Despite limited experience, programming the library was very easy. Thx for the great MongoDB-Documentation 🙂

the first robot test

Robot Remote Library

The robot remote library is also on board 🙂 Then you can start the library as a separate server. This is very useful if you want to use python instead of jython in the main test suite.

Before starting the tests you need to start the server by the folowing shell command:

MongoDB-Server Embedded

Since the 0.2-Version there is a keyword that starts a MongoDB-Server (of a given Version) within the tests . This is done by the Embedded MongoDB Library . The keyword downloads the server from the MongoDB-Webpage , extracts this to the home directory und starts the MongoDB Daemon in a seperate oprating system process (MongoDB is written in C++). At the end of test the daemon should be terminated by the keyword Shutdown Embedded , that’s a clean shutdown of the database.

One of the main benefits of the server integration is the resulting clarity of the Robot-Logs. The log messages of the MongoDB Server are written to the Robot-Log and can directly assigned to the keywords:

embeddedServer

Usage in other testing frameworks

The library has no dependencies to the robotframework, so you can also use the library with other testing frameworks (e.g. Junit , JBehave ). For this approach there is another download version without dependencies .

have fun with the library 🙂

//

More articles in this subject area

Discover exciting further topics and let the codecentric world inspire you.