Skip to content

desenvolvedor

Rodolfo Dirack edited this page Jul 2, 2021 · 23 revisions

Documentação do desenvolvedor

Principais funções

Asserções básicas

TEST_IGNORE

A função TEST_IGNORE é utilizada para ignorar um bloco de testes. Esta funciona por meio de uma chave "on/off" recebida através do parâmetro $1 que altera a variável global TEST_IGNORE_UNITY. Quando a variável TEST_IGNORE_UNITY é igual a 1 os testes são ignorados pela função principal TEST_UNITY, quando esta variável é igual a 0 os testes são realizados e considerados pela função TEST_UNITY. A utilização da função TEST_IGNORE ocorre como no exemplo de uso a seguir:

TEST_IGNORE on # Ligar a chave para ignorar testes
TEST_ASSERT_TRUE "2==2" #... testes ignorado
TEST_ASSERT_FALSE "2==3" #... teste ignorado
TEST_ASSERT_FALSE "3==3" #... teste ignorado
TEST_IGNORE off # Desligar a chave para ignorar testes
# Os testes a seguir serão realizados
TEST_ASSERT_TRUE "2==2" #... testes realizado
TEST_ASSERT_FALSE "3==3" #... teste realizado

Esta manipulação da variável global TEST_IGNORE_UNITY ocorre dentro de um bloco if simples a depender do parâmetro $1 passado a função TEST_IGNORE_UNITY.

TEST_IGNORE(){
        if [ "$1" == "on" ]
        then
                TEST_IGNORE_UNITY="1"
        elif [ "$1" == "off" ]
        then
                TEST_IGNORE_UNITY="0"
        fi
}

TEST_MESSAGE(){

    echo "$0:$BASH_LINENO:INFO: $1"

}

TEST_FAIL(){ TEST_UNITY 1 "$BASH_LINENO" "$FUNCNAME" }

TEST_FAIL_MESSAGE(){

    echo "$0:$BASH_LINENO:FAIL: $1"
    TEST_UNITY 1 "$BASH_LINENO" "$FUNCNAME"

}

TEST_PASS(){

    TEST_UNITY 0 "$BASH_LINENO" "$FUNCNAME"

}

TEST_PASS_MESSAGE(){

    echo "$0:$BASH_LINENO:PASS: $1"
    TEST_UNITY 0 "$BASH_LINENO" "$FUNCNAME"

}

Clone this wiki locally