-1

我应该把 Behave 的实现代码放在哪里,这样它就不会通过 Behave 的测试?此外,我是否需要导入任何内容或放入任何代码,以便我编写的代码链接到功能文件。

这是我的功能文件的摘录\steps\main.feature...

Feature: Main program
    Program allows users to create create and view development logs 

Scenario: User requests development logs for a particular user
    Given user has requested development logs for a given user
    Then the development logs for that user will show

以下是实施建议(来自运行行为):

@given(u'user has requested development logs for a given user')
def step_impl(context):
    raise NotImplementedError(u'STEP: Given user has requested development logs for a given user')

@then(u'the development logs for that user will show')
def step_impl(context):
    raise NotImplementedError(u'STEP: Then the development logs for that user will show')

我意识到这确实是基本信息,但文档中没有任何内容涵盖这一点,尽管谷歌上有很多教程,但没有一个涵盖这一点。我认为这太基本了。

4

1 回答 1

0

答案是三方面的:

  1. 我提出了一个未实现的错误,所以测试失败了。

  2. 在我的 Python 文件的顶部,我需要包含from behave import *.

  3. 我的 Python 文件需要是一个名为steps.

在查看Python TDD 目录结构的答案后,我通过反复试验自己解决了这个问题。

于 2015-03-22T02:10:43.267 回答