|
55 | 55 | * * ssl_cipher - list of one or more permissible ciphers to use for SSL encryption (MySQL specific, @see http://php.net/manual/de/ref.pdo-mysql.php#pdo.constants.mysql-attr-cipher) |
56 | 56 | * * databases - include more database configs and switch between them in tests. |
57 | 57 | * * initial_queries - list of queries to be executed right after connection to the database has been initiated, i.e. creating the database if it does not exist or preparing the database collation |
58 | | - * |
| 58 | + * * skip_cleanup_if_failed - Do not perform the cleanup if the tests failed. If this is used, manual cleanup might be required when re-running |
59 | 59 | * ## Example |
60 | 60 | * |
61 | 61 | * modules: |
|
69 | 69 | * cleanup: true |
70 | 70 | * reconnect: true |
71 | 71 | * waitlock: 10 |
| 72 | + * skip_cleanup_if_failed: true |
72 | 73 | * ssl_key: '/path/to/client-key.pem' |
73 | 74 | * ssl_cert: '/path/to/client-cert.pem' |
74 | 75 | * ssl_ca: '/path/to/ca-cert.pem' |
@@ -253,6 +254,7 @@ class Db extends CodeceptionModule implements DbInterface |
253 | 254 | 'waitlock' => 0, |
254 | 255 | 'dump' => null, |
255 | 256 | 'populator' => null, |
| 257 | + 'skip_cleanup_if_failed' => false, |
256 | 258 | ]; |
257 | 259 |
|
258 | 260 | /** |
@@ -614,6 +616,15 @@ public function _before(TestInterface $test) |
614 | 616 | parent::_before($test); |
615 | 617 | } |
616 | 618 |
|
| 619 | + public function _failed(TestInterface $test, $fail) |
| 620 | + { |
| 621 | + foreach ($this->getDatabases() as $databaseKey => $databaseConfig) { |
| 622 | + if (!empty($databaseConfig['skip_cleanup_if_failed'])) { |
| 623 | + $this->insertedRows[$databaseKey] = []; |
| 624 | + } |
| 625 | + } |
| 626 | + } |
| 627 | + |
617 | 628 | public function _after(TestInterface $test) |
618 | 629 | { |
619 | 630 | $this->removeInsertedForDatabases(); |
@@ -723,7 +734,8 @@ protected function loadDumpUsingDriver($databaseKey) |
723 | 734 | } |
724 | 735 |
|
725 | 736 | /** |
726 | | - * Inserts an SQL record into a database. This record will be erased after the test. |
| 737 | + * Inserts an SQL record into a database. This record will be erased after the test, |
| 738 | + * unless you've configured "skip_cleanup_if_failed", and the test fails. |
727 | 739 | * |
728 | 740 | * ```php |
729 | 741 | * <?php |
|
0 commit comments