0

I have 10 feature files out of which I want to exclude api.feature and integration.feature . How do I do it using behave?

behave --tags @test --no-capture --show-timings  -e (int|u)

behave --tags @test --no-capture --show-timings  -e api.feature -e integration.feature 

None of the above 2 options work.

Vincent Savard
  • 34,979
  • 10
  • 68
  • 73
user3179786
  • 123
  • 2
  • 12
  • I actually have behave setup. I copied out one of my feature files and renamed it to bob.feature. I executed the following command, and of my three feature files, only bob.feature was executed: `behave features/ -e some_other` – idjaw Feb 25 '16 at 18:35
  • -e works for me when I have to exclude only 1 pattern. How do I exclude multiple patterns? For. eg above, I have 2 files api.feature and integration.feature . How do I tell behave to exclude these 2 files in 1 pattern string ? or by specifying complete filenames (multiple patterns) ? – user3179786 Feb 25 '16 at 21:31
  • I just re-read the documentation and even looked back at the answer posted and it hit me. It's expecting a regex pattern: `behave -e "(api|integration)"`. With that, you can add as much complexity as you want to filter out what you don't want. – idjaw Feb 25 '16 at 21:46
  • Thank you "idjaw". It worked! – user3179786 Feb 25 '16 at 22:46
  • idjaw , Could you please point me to which documentation you looked at? – user3179786 Feb 25 '16 at 22:47
  • [here](https://pythonhosted.org/behave/behave.html#cmdoption-e). "regular expression pattern". When I saw that I decided to give it a regex and it worked. – idjaw Feb 25 '16 at 22:58

2 Answers2

0
-e, --exclude

Don’t run feature files matching regular expression PATTERN.

this answer was taken from here

Jay T.
  • 307
  • 1
  • 6
0

You were on the right track, but made a small mistake in your first example.

Behave supports ordinary re syntax as Python does. So in any place, where we see PATTERN reference, we can use it.

"|" is used for "OR" condition and I think the problem was that your shell interpreted it as a 'pipe' character. So we need to escape it with "\" character. Correct call should be next:

behave --tags @test --no-capture --show-timings  -e int\|u