How can i specify an order in mink/behat tests?
Asked Answered
M

2

6

I'm using mink/behat to test my website. I need certain features be executed before others. Is there a way to specify an order of execution?

For example: There are 3 features: Administration, Login, Buy I need to execute them in this order: Login, Administration, Buy

Thank you!

Mantoman answered 25/6, 2013 at 13:48 Comment(0)
M
9

Behat executes files in an alphabetic order. You could prefix them with a number to force the order.

However...

Scenarios are meant to be independent and the execution order shouldn't matter.

Marozik answered 2/7, 2013 at 5:36 Comment(3)
How would you then test very common use case of website that has to register user in order to use the same user in later tests? I know I can put user in fixtures, but that also shouldn't be a point. Also registering him in beginning of every feature is overkill.Hanway
@Hanway that's a new question, so you should ideally post it as a new question. However, you can handle that with a beforeSuite function in your context or by having a mock user created as some other pre-testing step. There are more answers I'd give if you posted a question ;)Bounty
It "shouldn't" matter does not mean it "could" matter - and you will only find out if the case is that you do have dependencies unless you have good isolation of tests - or you regularly run in random order. Preferably both.Cantrell
C
0

behat now allows you to specify an order from the existing Orderer implementations:

vendor/bin/behat --order=[random|reverse|null]

so for randon:

vendor/bin/behat --order=random

I believe you could also write your own. If you wish to control the order in terms of batches, e.g. set x scenarios need to run before set y this could be achieved by just tags and running the two separate suites in sequence.

Cantrell answered 16/2, 2023 at 14:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.