Codeception / Codeception/module-db

Make optional the auto-erase of the records, added by `haveInDatabase()`

Abierto
#68 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
23
Forks
31
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

#### Problem
Currently, all records, added by `haveInDatabase()` method during test, are automatically removed after the end of the test.
Although this is a documented behaviour, for me it adds more confusion than profit.

In case when I need all the changes, made during test, to disappear after the test, I can't rely solely on this behaviour, because changes may be done not only by `haveInDatabase()`. So I still need to use other things for keeping tests isolated (wrapping tests in transactions, or to re-populate database from dump before each test, etc).

And in other case, when I do not need tests isolation, I am ok with the fact that each test changes something in database, so auto-erasing some records only adds confusion for me.

So, I'd like to be able to turn this behaviour off in my tests.

Currently we have a `skip_cleanup_if_failed` configuration parameter, but it does not give full control over the auto-erase, because allows to omit it only when tests fail (which should be the default behaviour, IMHO). Also, its name is confusing (see [issue #67](https://github.com/Codeception/module-db/issues/67)).

#### Proposed solution
Let's add another boolean configuration parameter, responsible for this auto-erase. For example, `auto_erase`, or `cleanup` (could be used after renaming current `cleanup` to `repopulate` - see [issue #67](https://github.com/Codeception/module-db/issues/67))

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza localizando la implementación de haveInDatabase() y el manejo de la configuración de skip_cleanup_if_failed. Rastrea dónde se borran automáticamente los registros después de las pruebas y confirma después que la configuración booleana elegida puede desactivar ese comportamiento, preservando el valor predeterminado existente y el comportamiento de limpieza tras un fallo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
database, testing
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.