Robot Framework and Django

I am trying to use Robot Framework for acceptance testing of my django application.

The thing is, in order to test my django app, I need to call

./manage.py runserver

      

Start the server. Can I make a Robot Framework for this? And stop it after the tests, of course.

Or better yet, can you do to have test suites run under django's LiveServerTestCase?

+3


source to share


2 answers


The robot has a library named Process that is specifically designed to start and stop processes. You can use Start Process and end the process to start and stop the web server by installing the set and removing packages . It will look something like this:

*** Settings ***
| Library | Process
| Suite Setup | Start the webserver
| Suite Teardown | Stop the webdserver

*** Keywords ***
| Start the webserver
| | ${django process}= | Start process | python | manage.py
| | Set suite variable | ${django process}

| Stop the webserver
| | Terminate Process | ${django process}

      



Of course, you need to add some bullet checks, like making sure the process is actually running, and possibly catching errors if it doesn't crash. You probably need to provide an explicit path to manage.py as well, but hopefully this gives a general idea.

+1


source


Have a look at https://github.com/kitconcept/robotframework-djangolibrary which seems to handle exactly this.

Or, better yet, can you do to have test suites run under Django's LiveServerTestCase?



This is a much more interesting approach, as we could then mix the robot tests with other tests. I'll post here if I figure out how to do this.

+2


source







All Articles