猿问

Python Behave - ConfigError:[] 中没有步骤目录

按照设置行为的教程(https://behave.readthedocs.io/en/latest/tutorial.html),我收到一条ConfigError: No steps directory错误消息。


我的文件结构:


VS Code/TestingAutomationPOC/

VS Code/TestingAutomationPOC/features/

VS Code/TestingAutomationPOC/features/steps/

VS Code/TestingAutomationPOC/features/steps/tutorial.py

VS Code/TestingAutomationPOC/feature/tutorial.feature

通过 pip 安装行为(1.2.6)。


添加"python.linting.pylintArgs": ["--load-plugin","pylint_protobuf"]到用户设置中,修复了我的导入问题,但对这个 ConfigError 没有帮助。


来自tutorial.py:


from behave import *


@given('we have behave installed')

def step_impl(context):

    pass


@when('we implement a test')

def step_impl(context):

    assert True is not False


@then('behave will test it for us!')

def step_impl(context):

    assert context.failed is False

来自tutorial.feature:


Feature: showing off behave


  Scenario: run a simple test

     Given we have behave installed

      When we implement a test

      Then behave will test it for us!

我究竟做错了什么?


Smart猫小萌
浏览 664回答 3
3回答

慕哥6287543

你可以试试这个命令:behave **/feature_file_name

慕容3067478

我遇到了类似的问题。首先你需要确保你的文件夹路径是正确的。第二件事,steps在您的项目文件夹中创建文件features夹。现在运行behave带有功能文件名或不带文件名的命令,它应该可以工作。├── feature [folder]│   |── steps [folder]├── filename.feature [file]

慕桂英4014372

您在 VisualStudio 中的工作目录可能不正确。提示:打印命令行如何执行行为打印此执行的当前工作目录(cmd-shell: %CD%)提供您自己的 python 脚本“my_behave.py”来运行行为。它可以轻松地显示/打印上面的诊断信息。
随时随地看视频慕课网APP

相关分类

Python
我要回答