Answer the question
In order to leave comments, you need to log in
How to add data to the database before acceptance testing?
I recently started to delve into testing using Codeception. It is not clear how to properly use the database.
There is such a functionality - the admin, adds a record, users leave comments under it. To leave a comment, you need to know the id of the post.
In Unit tests, before each test, I created an entry in the database (through modules I accessed ZF2, then to the database mapper). And he knew exactly the number.
If I connect the ZF2 module during the acceptance test, then an error appears
Fatal error: Cannot redeclare _generated\AcceptanceTesterActions::switchToIframe()
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- \Helper\Acceptance
- Db
- ZF2
config:
WebDriver:
url: 'http://test.ru/'
browser: chrome
port: 4444
Answer the question
In order to leave comments, you need to log in
It turned out that everything is quite simple -
there is a function
that adds data to the database, after the test the function for deleting the added data is automatically called.
PS The name is not explicit, until I got into the code - I did not understand what it was doing. Why can't you call add/insert?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question