1

I followed the official Codeception guide (from their website of course) and I created a simple test written in Gherkin.

With the command codecept gherkin:snippets command, I printed all methods I must implement. Then I copied these methods to the tests/_support/AcceptanceTester.php file.

My question is: today, it's a sample test, but tomorrow, if I must create a lot of acceptance tests, how do I organize my code ?

I suppose I must write each main scenario in several PHP files. But, where I can save these files? How do I link these files together?

Let's say I must create two big scenarios of acceptance tests. The Scenario A can be run alone, but the Scenario B must be run after the Scenario A.

Where do I need to create the files A and B? And, how can I "say" to Codeception I can run the Scenario B only after the A has been executed?

Sorry for my English, I hope my questions are clear.

Oliver Maksimovic
  • 3,204
  • 3
  • 28
  • 44
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
  • Possible duplicate of [Codeception, write acceptance tests with the pageObject design pattern and gherkin](https://stackoverflow.com/questions/52132683/codeception-write-acceptance-tests-with-the-pageobject-design-pattern-and-gherk) – spacecodeur Sep 02 '18 at 09:51

1 Answers1

0

You can tell Codeception that a scenario depends on something else by using @depends followed by the test signature. According to the documentation:

And what is more interesting, you can make tests to depend on feature scenarios. Let’s say we have login.feature file with “Log regular user” scenario in it. In this case you can specify that every test which requires login to pass to depend on “Log regular user” scenario:

@depends login:Log regular user

Inside @depends block you should use test signature. Execute your feature with dry-run to see signatures for all scenarios in it. By marking tests with @depends you ensure that this test won’t be executed before the test it depends on.

Oliver Maksimovic
  • 3,204
  • 3
  • 28
  • 44
  • thank you for your answer. I'm sorry, I created a new post with a full exemple of pageObject/stepObject/Gherkin here (https://stackoverflow.com/questions/52132683/codeception-write-acceptance-tests-with-the-pageobject-design-pattern-and-gherk). I close this post. – spacecodeur Sep 02 '18 at 09:50