E
E
Evgeny Bukharev2019-05-30 21:09:42
Yii
Evgeny Bukharev, 2019-05-30 21:09:42

Why do tests run one at a time, but errors occur in some tests when they are run together?

We have the Yii2 framework, with a structure like yii2-advanced, 2 types of unit and functional tests, fixtures are also used here and there.
When running tests one by one, there are no errors, when running all through codecept run without additional parameters, errors fall out in some tests. When run with the -vvv option, it tends to have problems loading fixtures. There is information on the network that with frameworks, in particular with functional tests, there are problems with running all the tests due to the fact that the execution takes place in one process, and the tests may conflict with each other.
How to solve this problem by forcing the tests to run all together?

Codeception PHP Testing Framework v2.4.0
Powered by PHPUnit 7.1.4 by Sebastian Bergmann and contributors.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2019-05-30
@evgenybuckharev

Because global states.
In the object, the state does not change between tests
How to treat.
If because of them, then it is possible to easily cure it - do a cleanup before each test and populate, that is, preload fixtures again
https://codeception.com/docs/modules/Db#Populator
Or create your own unique set of fixtures for each test (I chose this option), it is fast, a little gemmorno

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question