Codeception / Codeception/module-db

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

Aberta
#68 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
PHP
Estrelas
23
Forks
31
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

#### 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))

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece localizando a implementação de haveInDatabase() e o tratamento da configuração de skip_cleanup_if_failed. Rastreie onde os registros são apagados automaticamente após os testes e, em seguida, confirme que a configuração booleana escolhida pode desativar esse comportamento, preservando o padrão existente e o comportamento de limpeza em caso de falha.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
php
Domínio
database, testing
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.