2014-11-21 100 views
3

我正在尝试使用Robot Framework来接受测试我的django应用程序。Robot Framework和Django

的事情是,来测试我的Django应用程序,我需要调用

./manage.py runserver 

要启动服务器。我可以让Robot Framework为我做吗?当然在测试之后停下来。

或者,更好的是,可以使测试套件在django LiveServerTestCase下运行?

+0

什么是操作系统? – 2014-11-21 07:54:14

+0

我正在使用OSX优胜美地 – 2014-11-21 08:08:58

回答

1

机器人有一个名为Process的库,它专门用于启动和停止过程。您可以使用Start ProcessTerminate Process关键字通过suite setup and suite teardown启动和停止网络服务器。这将是这个样子:

*** 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} 

当然,你想添加一些子弹打样如确保实际开始的过程中,可能捕捉错误,如果它不完全退出。你也可能需要给manage.py一个明确的路径,但希望这给出了总体思路。

2

看看https://github.com/kitconcept/robotframework-djangolibrary这似乎处理完全这一点。

或者,甚至更好,可以使测试套件在Django LiveServerTestCase下运行?

这是一个非常有趣的方法,因为我们可以将机器人测试与其他测试混合使用。如果我找出如何去做,我会在这里发布。