This simple example demonstrates how to use C language from Robot Framework test libraries. The example uses Python's standard ctypes module, which requires that the C code is compiled into a shared library. This version is implemented and tested on Linux, but adapting it to other operating systems would require only changing compilation and name of the produced shared library.
See also Robot Framework Demo , Web testing with Robot Framework and Selenium2Library and Acceptance Test Driven Development with Robot Framework demo projects.
The latest demo package is available on the project downloads as robotframework-c-example-<date>.zip. After downloading and unzipping the package, you should have all the files in a directory robotframework-c-example.
The demo application is a very simple login system (login.c), that validates the given user name and password and returns the status. There are two valid username password combinations: demo/mode and john/long.
Before running the demo, you need to compile the demo application by simply running make in the directory that was created when you extracted the demo package. This will create shared library liblogin.so.
The if __name__ == '__main__' block in LoginLibrary.py is not used by the executed tests, but it allows using the library code as a tool for manual testing. You can test this handy behavior on the command line:
python LoginLibrary.py demo mode python LoginLibrary.py demo invalid
login_tests.robot test suite contains all tests for this project. It contains separate tests for valid and invalid login.
Notice that although the file has a fancy .robot extension, it is actually a normal plain text file. The extension could be changed to .txt and Robot Framework would still be able to run it.
pip install robotframework
When Robot Freamework is installed, the demo can be executed using pybot command:
All the test should pass.