Testes na trilha OpenEuphoria

Aprenda a testar seus exercícios de OpenEuphoria no Exercism


Rodando os testes

No diretório do exercício, rode exercism test ou eutest. O Euphoria vai então rodar t_<exercise>.e contra a sua solução.

Lendo a saída

No começo de um exercício, o arquivo da sua solução não tem valor de retorno e vai quebrar quando for rodado.

C:\path\to\leap.ex:3
<0120>:: no value returned from function
end function
           ^

FAILURE: t_leap.e EUPHORIA error with status 1

Test results summary:
    FAIL: t_leap.e
Files (run: 1) (failed: 1) (0% success)

Isso é esperado. Implemente a função e depois rode de novo para ver quais testes passam e quais falham.

interpreting t_leap.e:
  passed: year not divisible by 4 in common year
  failed: year divisible by 2, not divisible by 4 in common year, expected: FALSE but got: TRUE
  failed: year divisible by 4, not divisible by 100 in leap year, expected: TRUE but got: FALSE
  ...
  9 tests run, 6 passed, 3 failed, 67% success
FAILURE: t_leap.e program died with status 1

Test results summary:
    FAIL: t_leap.e
Files (run: 1) (failed: 1) (0% success)

Trabalhando os testes aos poucos

Uma boa forma de começar é comentar todos os testes, menos o primeiro, em t_<exercise>.e.

test_false("year not divisible by 4 in common year", leap(1800))
-- test_false("year divisible by 100 but not by 3 is still not a leap year", leap(1900))
-- test_false("year divisible by 2, not divisible by 4 in common year", leap(1970))

Resolva um de cada vez, descomentando o próximo teste assim que o atual passar. Quando todos os testes estiverem passando, você concluiu o exercício.