pengovbr / mod-sei-pen

Módulo de Integração ao Tramita.GOV.BR
30 stars 23 forks source link

Refatoração de testes #558

Open mateussbh opened 2 months ago

mateussbh commented 2 months ago

Sua solicitação de melhoria está relacionada a um problema? Por favor descreva. Hoje muitos testes estão demorando demasiado tempo para concluírem e estão muito verbosos, prejudicando a execução tempestiva do teste automatizado completo e piorando sua eficiência. Alguns chegam a demorar 5 a 10 minutos somente para chegar no ponto que efetivamente ocorreria o teste da funcionalidade em questão.


Descreva a solução que você gostaria Faz-se necessária a refatoração dos testes funcionais, de modo que esses passem a usar classes de fixtures e DTOs, e para que o teste gaste tempo prioritariamente testando o que está proposto no escopo, e deixando a cargo das Fixtures a inclusão de dados e a montagem do cenário que antecede ao teste em si da funcionalidade, objetivando testes mais limpos e fáceis de entender.

Para esta issue, foram selecionados os seguintes testes a serem refatorados, são eles:

Favor anexar evidência com a execução do teste com sucesso.

Descreva alternativas que você considerou N/A


amelquia commented 1 month ago

19/08/24 - Daily Essa issue encontra-se pausada, pois o Paul está finalizando as correções encontradas na issue 331 (Ajustes necessários), após a revisão de código realizada pelo Marcus.

NinetiesPaul commented 1 month ago

Aberto PR #603

Com os testes ComponentesDigitais movidos para nova issue própria, dos testes que sobraram: TramiteProcessoValidacaoEnvioTest: Não precisou de refatoração pois já é um teste curto, levando menos de 1 minuto para executar TramiteRecebimentoDocumentoAvulsoTest: Refatorado TramiteRecebimentoInteressadosDuplicadosTest: Não precisou de refatoração pois já é um teste curto, levando menos de 1 minuto para executar

Seguem evidencias: 558 TramiteProcessoValidacaoEnvioTest 558 TramiteRecebimentoDocumentoAvulsoTest 558 TramiteRecebimentoInteressadosDuplicadosTest

amelquia commented 3 weeks ago

02/09/24 Issue transferida para a sprint49, aguardando a Revisão de Código.

amelquia commented 2 weeks ago

10/09/24 - Daily Revisão de Código: Mauro Costa.

Mauro1706 commented 2 weeks ago

Revisão de código finalizada, e não encontrado nenhum erro e/ou sugestão.

sergioadao commented 1 week ago

Boa tarde @amelquia, @NinetiesPaul e @mateussbh ....testes realizados e funcionaram ok.

OBS: Para execução dos testes é necessário o ambiente SEI configurado (unidades). Também, é necessário o phpunit.xml conter as unidades configuradas.Testes:

Seguem evidências:

======================================================================================

1) teste=TramiteRecebimentoDocumentoAvulsoTest

$ make teste=TramiteRecebimentoDocumentoAvulsoTest test-functional docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env up -d WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 11/11 ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-php-test-unit-1 Started 0.7s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s ✔ Container funcional-php-test-functional-1 Started 0.8s docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run -w /tests php-test-functional bash -c './composer.phar install' WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zend-mime is abandoned, you should avoid using it. Use laminas/laminas-mime instead. Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Generating autoload files 27 packages you are using are looking for funding. Use the composer fund command to find out more! docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run --rm php-test-functional /tests/vendor/bin/phpunit -c /tests/phpunit.xml /tests/tests/TramiteRecebimentoDocumentoAvulsoTest.php ; WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( PHPUnit 8.5.38 by Sebastian Bergmann and contributors.

Runtime: PHP 7.3.33 with Xdebug 3.0.4 Configuration: /tests/phpunit.xml

. .... 5 / 5 (100%)

Time: 12.25 minutes, Memory: 26.00 MB

OK (5 tests, 114 assertions)

===========================================================================================================

2) teste=TramiteProcessoValidacaoEnvioTest

$ make teste=TramiteProcessoValidacaoEnvioTest test-functional docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env up -d WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 11/11 ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-php-test-unit-1 Started 0.7s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s ✔ Container funcional-php-test-functional-1 Started 0.6s docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run -w /tests php-test-functional bash -c './composer.phar install' WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zend-mime is abandoned, you should avoid using it. Use laminas/laminas-mime instead. Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Generating autoload files 27 packages you are using are looking for funding. Use the composer fund command to find out more! docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run --rm php-test-functional /tests/vendor/bin/phpunit -c /tests/phpunit.xml /tests/tests/TramiteProcessoValidacaoEnvioTest.php ; WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-b871f89cacc0 funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( PHPUnit 8.5.38 by Sebastian Bergmann and contributors.

Runtime: PHP 7.3.33 with Xdebug 3.0.4 Configuration: /tests/phpunit.xml

. 1 / 1 (100%)

Time: 55.06 seconds, Memory: 12.00 MB

OK (1 test, 2 assertions)

=====================================================================================================================

3) make teste=TramiteRecebimentoInteressadosDuplicadosTest

$ make teste=TramiteRecebimentoInteressadosDuplicadosTest test-functional docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env up -d WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-b871f89cacc0 funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 11/11 ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-php-test-unit-1 Started 0.8s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s ✔ Container funcional-php-test-functional-1 Started 0.7s docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run -w /tests php-test-functional bash -c './composer.phar install' WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-b871f89cacc0 funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( Installing dependencies from lock file (including require-dev) Verifying lock file contents can be installed on current platform. Nothing to install, update or remove Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zend-mime is abandoned, you should avoid using it. Use laminas/laminas-mime instead. Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead. Generating autoload files 27 packages you are using are looking for funding. Use the composer fund command to find out more! docker compose -f tests_super/funcional/docker-compose.yml --env-file tests_super/funcional/.env run --rm php-test-functional /tests/vendor/bin/phpunit -c /tests/phpunit.xml /tests/tests/TramiteRecebimentoInteressadosDuplicadosTest.php ; WARN[0000] /home/toor/Documentos/ministerio_economia/aplicacao_sei/sei_versoes/sei-trad/src/sei/web/modulos/mod-sei-pen/tests_super/funcional/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion WARN[0000] Found orphan containers ([funcional-php-test-functional-run-20e020a4cd2f funcional-php-test-functional-run-b871f89cacc0 funcional-php-test-functional-run-8b522f90ce18 funcional-php-test-functional-run-59a713a33865 funcional-php-test-functional-run-6fda2297d172 funcional-php-test-functional-run-884b5987f30f funcional-php-test-functional-run-0eb245c807fa funcional-php-test-functional-run-f99642b3f110]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Creating 9/0 ✔ Container funcional-org2-memcached-1 Running 0.0s ✔ Container funcional-org1-database-1 Running 0.0s ✔ Container funcional-org2-database-1 Running 0.0s ✔ Container funcional-org1-memcached-1 Running 0.0s ✔ Container funcional-smtp-1 Running 0.0s ✔ Container funcional-org1-http-1 Running 0.0s ✔ Container funcional-org2-http-1 Running 0.0s ✔ Container funcional-proxy-1 Running 0.0s ✔ Container funcional-selenium-1 Running 0.0s Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-( PHPUnit 8.5.38 by Sebastian Bergmann and contributors.

Runtime: PHP 7.3.33 with Xdebug 3.0.4 Configuration: /tests/phpunit.xml

. 1 / 1 (100%)

Time: 1.18 minutes, Memory: 14.00 MB

OK (1 test, 12 assertions)