user5653362 user5653362 - 6 months ago 63
Python Question

Python behave giving ConfigError: No feature files in ""

I have organised my files like this.

features/
features/example.feature
features/steps/
features/steps/example_steps.py


Here is the code I am using:

# -- FILE: features/example.feature
Feature: Showing off behave

Scenario: Run a simple test
Given we have behave installed
When we implement 5 tests
Then behave will test them for us!

# -- FILE: features/steps/example_steps.py
from behave import given, when, then, step

@given('we have behave installed')
def step_impl(context):
pass

@when('we implement {number:d} tests')
def step_impl(context, number): # -- NOTE: number is converted into integer
assert number > 1 or number == 0
context.tests_count = number

@then('behave will test them for us!')
def step_impl(context):
assert context.failed is False
assert context.tests_count >= 0


But when I type behave it gives me this error -


ConfigError: No feature files in "/Users/chirag/Desktop/features"

Answer

I copy and pasted your code, using the same file structure, and behave ran just fine:

(.venv27) ➜  behave_test behave
Feature: Showing off behave # features/example.feature:1

  Scenario: Run a simple test          # features/example.feature:3
    Given we have behave installed     # features/steps/example_steps.py:3 0.000s
    When we implement 5 tests          # features/steps/example_steps.py:7 0.000s
    Then behave will test them for us! # features/steps/example_steps.py:12 0.000s

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.000s
(.venv27) ➜  behave_test

This was with both python 3.5 and 2.7. The only way I could get your error message was to rename the feature file to example.feature.bak, or to run behave from the wrong directory.