use*_*861 2 linux selenium jenkins selenium-chromedriver python-behave
我有一个 python Web 应用程序,它使用Behavior 进行行为测试。我有 5 个 *.feature 文件,当我在本地和我们的 Jenkins 构建服务器上运行它们时,每个文件都需要几分钟才能运行。我想并行运行这五个文件而不是顺序运行以节省时间。我可以在本地执行此操作,但不能在我的构建服务器上执行此操作。详细信息如下:
在 Windows 上本地运行:
behave.exe --include "file_01.feature"
behave.exe --include "file_02.feature"
behave.exe --include "file_03.feature"
behave.exe --include "file_04.feature"
behave.exe --include "file_05.feature"
构建服务器在 Linux 上运行:
当我尝试使用类似的命令运行所有五个文件时,某些行为场景会出现错误。错误是以下三个之一:
抛出这些错误的行为场景似乎随着每次测试运行而改变。
我怀疑在运行行为测试中 Chrome 驱动程序之间存在一些共享资源,但我不确定。我无法解释为什么这在本地适用于我,但在我的构建服务器上却不起作用。我也无法解释为什么 3 个文件可以工作,但 5 个文件就不行。
在尝试同时运行多个行为测试时,有人看到过这样的错误吗?或者你知道我应该寻找什么吗?我的项目足够大,很难将我的问题的最小示例放在一起。这就是为什么我没有发布任何代码。我只是想知道我应该寻找什么,因为我不知所措。
小智 6
这就是我并行运行多个功能的方式。
from behave.__main__ import main as behave_main
@step(u'run in parallel "{feature}" "{scenario}"')
def step_impl(context, feature, scenario):
t = threading.Thread(
name='run test parallel',
target=parallel_executor,
args=[context, feature, scenario])
#args=[context, 'parallel_actions.feature', 'Make Cab-Cab communication'])
t.start()
def parallel_executor(context, feature_name, scenario):
os.chdir(testenv.PARALLEACTIONS_PATH)
behave_main('-i "{}" -n "{}" --no-capture --no-skipped'.format(feature_name, scenario))
Run Code Online (Sandbox Code Playgroud)
并具有特色
Feature: testing parallel
Scenario: parallel run
When run in parallel "parallel_actions-1.feature" "Make Cab-Cab communication"
And run in parallel "parallel_actions-1.feature" "Another Scenario"
And run in parallel "another_parallel.feature" "Another Scenario 2"
Run Code Online (Sandbox Code Playgroud)
我只是创建新线程并直接调用behavior执行器,你不需要分别调用behave.exe进程5次而是一次。所有功能均同时并行执行。
我无法回答您的消息错误,但您可以尝试另一种方法(更行为的方式)来并行运行行为功能。
归档时间: |
|
查看次数: |
4270 次 |
最近记录: |