PyCharm: How to run behave.exe?
Asked Answered
M

5

6

I want to use behave lib in my program. I write code as in behave-tutorial. But, when I "Run" my tutorial-project, I see in PyCharm-console:

C:\Python27\virtualenv\Scripts\python.exe "C:/Program Files (x86)/JetBrains/PyCharmProjects/tutorial/steps/tutorial.py"
Process finished with exit code 0

I think what I must to use behave.exe for run my project:

C:\Python27\virtualenv\Scripts\behave.exe

How to get it?

Moonlight answered 7/4, 2013 at 7:45 Comment(3)
PyCharm has no Behave support yet: youtrack.jetbrains.com/issue/PY-8427. You can use external tools to run custom executables as a workaround.Corsetti
Thank you! I add "behave.exe" to External tools.Moonlight
If I add behave.exe as External tool giving it a path to my feature folder as working directory, for another project I have to add ANOTHER External tool record with a different working directory?Hospitalization
C
5

You can configure your run as per your purpose please have a look to screenhots here:

enter image description here

enter image description here

enter image description here

taken from: http://automated-testing.info/t/bdd-framework-debug-testov-stepov/3392/3

Charlatan answered 3/10, 2013 at 13:0 Comment(1)
The instructions from @mykhailo-poliarush worked for me, but instead of behave-script.py I had to find and run the behave script. In my virtual environment this was: ~/.virtualenvs/my_project_virtualenv/bin/behave (Note: I'm using behave==1.2.3 on a Mac)Thermic
S
3

Even though behave support is now in the Professional Edition, it's currently not in the Community Edition.

You can still call the behave module for a given feature directory.

Add a Python Run configuration, with no script and these options:

Interpreter options: -m behave
Working directory: path/to/feature/directory

Sauceda answered 29/6, 2015 at 7:54 Comment(0)
C
2

I tinkered around with previous answers and got PyCharm CE 5.x working with Behave I have python 2.7 installed system-wide, and behave installed via PyCharm package management
Here is my run config:

Script: put dot (.) in here [this way PyCharm recognizes the configuration as valid and doesn't show red cross mark]
Working Directory points to the dirctory where .feature file is
Interpreter options: -m behave

Chantellechanter answered 24/1, 2016 at 0:47 Comment(0)
C
2

For PyCharm Community 2016.3 on mac, setup a run configuration with:

  • Script: /usr/local/bin/behave
  • Script Parameters: path/to/feature/directory
  • Working Directory: path/to/project/directory

This way the run & DEBUG both work.

Cataplasia answered 3/1, 2017 at 13:48 Comment(0)
T
0

I have 2 features file (createX.feature and createY.feature) at feature directory but I want to select only 1

My configuration is

  • Script: createY.feature
  • Script parameters: --tags=@int --tags=@e2e
  • Interpreter options: -m behave
  • Working directory: $features_directory

The "Run" window shows this execution command

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -m behave createY.feature --tags=@int --tags=@e2e

but pycharm chooses the other feature file :(

But if I run the command at a terminal window, the command works!!

Edit: I have changed the feature file I want to execute for a better understanding: I try to execute the last one following alphabetical order

Edit 2: Solved It seems that behave does not like to have "scratch" files for control tasks at steps directory ... Once I deleted them, that handsome configuration works!!

Tumblebug answered 7/4, 2017 at 7:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.