Skip to content
Rodolfo Dirack edited this page Nov 20, 2021 · 8 revisions

Bem vindo ao shellUnity wiki!

Esta biblioteca é um framework de testes unitários em Shell Script contém um conjunto de funções para teste unitário de scripts. São funções básicas para verificar igualdade entre variáveis do Shell e strings, bem como verificar se arquivos e diretórios existem e etc.

Instalação

A forma mais simples de utilizar a shellunity é chamando a biblioteca de funções no início do Shell Script:

source shellunity

As funções serão carregadas e estarão disponíveis na memória no momento da execução do script com a suíte de testes.

Saída esperada

A shellUnity é baseada no projeto Unity, um framework para testes unitários em C. A saída esperada para uma suíte de testes é semelhante a do Unity. A seguir um exemplo de saída esperada após rodar a suíte de testes:

./test_example.sh 
./test_example.sh:24:INFO: Mensagem qualquer
./test_example.sh:27:TEST_ASSERT_EQUAL:PASS
./test_example.sh:28:TEST_PASS:PASS
./test_example.sh:29:PASS: Mensagem passou
./test_example.sh:29:TEST_PASS_MESSAGE:PASS
./test_example.sh:30:TEST_ASSERT_NOT_EQUAL:PASS
./test_example.sh:31:TEST_ASSERT_TRUE:PASS
./test_example.sh:32:TEST_ASSERT_FALSE:PASS
./test_example.sh:33:TEST_ASSERT_EQUAL_STRING:PASS
./test_example.sh:36:INFO: TESTES IGNORADOS
./test_example.sh:38:TEST_PASS:IGNORED
./test_example.sh:39:TEST_FAIL:IGNORED
./test_example.sh:43:TEST_ASSERT_EQUAL:FAIL
./test_example.sh:44:TEST_FAIL:FAIL
./test_example.sh:45:FAIL: Mensagem falhou
./test_example.sh:45:TEST_FAIL_MESSAGE:FAIL
./test_example.sh:46:TEST_ASSERT_NOT_EQUAL:FAIL
./test_example.sh:47:TEST_ASSERT_TRUE:FAIL
./test_example.sh:48:TEST_ASSERT_FALSE:FAIL
./test_example.sh:49:TEST_ASSERT_EQUAL_STRING:FAIL

-----------------------
16 Tests 7 Failures 2 Ignored
FAIL

Clone this wiki locally