Where's the code that's running the migration before the test is run? Couldn't you just do a dump of your test database and set Codeception to revert to that after all the tests have been executed?
Nov 26, 2014
11
Level 6
Codeception doesn't roll back the database
Hi guys,
I have a login test, which works fine on the first run
vendor/bin/codecept run functional
Codeception PHP Testing Framework v2.0.2
Powered by PHPUnit 4.3.5 by Sebastian Bergmann.
Functional Tests (1) -----------------------------------------------------------------------------------------------
Trying to log in to my account (LoginCept) Ok
--------------------------------------------------------------------------------------------------------------------
Time: 4.51 seconds, Memory: 23.00Mb
OK (1 test, 3 assertions)
but if I ran it again, it fails, because the database contains the data from the previous test and my user's account id won't match.
Functional Tests (1) -----------------------------------------------------------------------------------------------
Trying to log in to my account (LoginCept) Fail
--------------------------------------------------------------------------------------------------------------------
Time: 4.72 seconds, Memory: 23.25Mb
There was 1 failure:
---------
1) Failed to log in to my account in LoginCept (/home/vagrant/Sites/Clients/Pazo/CRM/app/tests/functional/LoginCept.php)
Couldn't see current url equals "/1/dashboard":
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'/1/dashboard'
+'/2/dashboard'
Scenario Steps:
6. I see current url equals "/1/dashboard"
5. I click "Login"
4. I fill field "password","secret"
3. I fill field "email","test@example.com"
2. I am on page "/login"
1. I have a user {"user":{"email":"test@example.com","password":"secret"},"user_meta":{"first_name":"Test","last_name":"User"},"account":{"plan":"trial"},"account_meta":{"name":"My Awesome Company"}}
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Any idea how to fix this?
Please or to participate in this conversation.