LSLínguas Sem BenaventeInglês para brasileiros

Aula

Testes em inglês básico

Nível: A2

Objetivo

Usar o vocabulário básico de teste em inglês (unit test, integration test, expected result, actual result, pass, fail) e escrever uma descrição simples de teste em frases curtas.

Explicação

Em projetos de software, tests verificam se o código funciona como esperado. Existem dois tipos comuns em conversas diárias de equipe:

  • Unit test: testa uma parte pequena e isolada do código, geralmente uma única função.
  • Integration test: testa várias partes trabalhando juntas, por exemplo dois módulos ou um serviço com seu banco de dados.

Cada teste compara dois valores:

  • Expected result (resultado esperado): o que o código deveria fazer.
  • Actual result (resultado atual): o que o código realmente fez.

Quando os dois valores são iguais, o teste passes (passa). Quando são diferentes, o teste fails (falha).

Uma descrição simples de teste segue um padrão curto em quatro linhas:

> Test: add two positive numbers. > Expected result: 5. > Actual result: 5. > Result: pass.

Use verbos simples para descrever o que o teste faz: `checks`, `returns`, `adds`, `rejects`, `multiplies`. Para descrever uma falha, escreva `fails because the function returns 0 instead of 5` ou `fails because the wrong error message is shown`.

Quando um teste falha, o developer (desenvolvedor) fixes the bug (conserta o defeito) e runs the test (executa o teste) novamente. Um conjunto de testes é chamado de test suite, e o resumo com a lista de pass e fail é o test report.

Exemplos

InglêsTraduçãoObservação
This unit test checks the add function.Este teste unitário verifica a função de soma.Unit test + checks + nome da função.
The expected result is 5, but the actual result is 4.O resultado esperado é 5, mas o resultado atual é 4.Expected = esperado; actual = atual.
The test passed after the fix.O teste passou depois do conserto.Pass no passado: passed.
The test failed because the function returned 0.O teste falhou porque a função retornou 0.Fail + because + causa.
I need to run the integration test again.Preciso executar o teste de integração de novo.Run + test = executar o teste.

Erros comuns

  • Trocar expected e actual: expected é o que você quer que aconteça, actual é o que realmente aconteceu.
  • Escrever 'the test is pass' em vez de 'the test passes' (presente) ou 'the test passed' (passado).
  • Confundir result com return: o teste tem um result (pass/fail); a função tem um return (valor de saída).
  • Dizer 'I make a test' em vez de 'I write a test' (criar) ou 'I run a test' (executar).
  • Escrever 'fail' como adjetivo: use 'the test fails' ou 'the test failed', nunca 'the test is fail'.

Prática guiada

Complete a descrição de teste em quatro linhas:

  • Test: multiply two numbers.
  • Expected result: 12. Actual result: 12. Result: pass.

  • Test: divide by zero.
  • Expected result: error. Actual result: error. Result: pass.

  • Test: login with a wrong password.
  • Expected result: error message. Actual result: login success. Result: fail.

Observe que a seção Result resume o teste em uma única palavra: pass ou fail.

Resumo

Testes verificam se o código funciona. Unit test cobre uma parte pequena; integration test cobre várias partes juntas. Expected result é o que você quer; actual result é o que aconteceu. Pass significa igual; fail significa diferente. Uma descrição simples segue o padrão Test / Expected result / Actual result / Result.

Vocabulário

Palavras principais

15 itens
unit testteste unitário

This unit test checks the add function.

Este teste unitário verifica a função de soma.
integration testteste de integração

We need an integration test for the API and the database.

Precisamos de um teste de integração para a API e o banco de dados.
expected resultresultado esperado

The expected result is 5.

O resultado esperado é 5.
actual resultresultado atual

The actual result is 4.

O resultado atual é 4.
passpassar (no teste)

The test passed after the fix.

O teste passou depois do conserto.
failfalhar (no teste)

The test failed because the function returned 0.

O teste falhou porque a função retornou 0.
run a testexecutar um teste

I need to run the test again.

Preciso executar o teste de novo.
write a testescrever um teste

She wrote a test for the login function.

Ela escreveu um teste para a função de login.
test casecaso de teste

Each test case describes one scenario.

Cada caso de teste descreve um cenário.
test reportrelatório de testes

The test report shows three failures.

O relatório de testes mostra três falhas.
developerdesenvolvedor

The developer fixed the bug.

O desenvolvedor consertou o defeito.
bugdefeito, bug

We found a bug in the login function.

Encontramos um defeito na função de login.
fixconsertar

I need to fix this bug.

Preciso consertar esse defeito.
checkverificar

The test checks the add function.

O teste verifica a função de soma.
returnretornar

The function returns 0 instead of 5.

A função retorna 0 em vez de 5.

História

História: Testes em inglês básico

Nível: A2

História em inglês

Sam writes a unit test

On Monday morning, Sam, a junior developer, opened his project and read the task: add a new function to calculate the total price of an order. Before he wrote the function, he decided to write a unit test first. The test had a simple description: Test: add two items to an order. Expected result: the sum of the two prices. Actual result: not checked yet. Result: not run. Sam ran the test, and of course it failed because the function did not exist. He looked at the test report and saw the red message: test failed: function addOrderItem is missing.

Fixing the bug and running an integration test

Sam wrote the function, then ran the unit test again. This time the test passed: the actual result was the sum of the two prices, exactly as the expected result. He felt good, but his teammate Marta asked, "Did you write an integration test for the whole checkout?" Sam said, "No, I didn't. I only wrote a unit test." Together they wrote an integration test that checked the order, the payment, and the email confirmation. The integration test failed because the email service returned a timeout. Sam fixed the bug in the email step, ran the test again, and the test passed. At the end of the day, the test report showed 12 tests passed and 0 failed.

Tradução linha por linha

InglêsTradução
On Monday morning, Sam, a junior developer, opened his project and read the task: add a new function to calculate the total price of an order.Na segunda-feira de manhã, Sam, um desenvolvedor júnior, abriu o projeto e leu a tarefa: adicionar uma nova função para calcular o preço total de um pedido.
Before he wrote the function, he decided to write a unit test first.Antes de escrever a função, ele decidiu escrever um teste unitário primeiro.
The test had a simple description: Test: add two items to an order. Expected result: the sum of the two prices. Actual result: not checked yet. Result: not run.O teste tinha uma descrição simples: Teste: adicionar dois itens a um pedido. Resultado esperado: a soma dos dois preços. Resultado atual: ainda não verificado. Resultado: ainda não executado.
Sam ran the test, and of course it failed because the function did not exist.Sam executou o teste e, claro, ele falhou porque a função não existia.
He looked at the test report and saw the red message: test failed: function addOrderItem is missing.Ele olhou para o relatório de testes e viu a mensagem em vermelho: teste falhou: a função addOrderItem está ausente.
Sam wrote the function, then ran the unit test again.Sam escreveu a função e depois executou o teste unitário de novo.
This time the test passed: the actual result was the sum of the two prices, exactly as the expected result.Dessa vez o teste passou: o resultado atual era a soma dos dois preços, exatamente como o resultado esperado.
He felt good, but his teammate Marta asked, "Did you write an integration test for the whole checkout?"Ele se sentiu bem, mas a colega Marta perguntou: "Você escreveu um teste de integração para o checkout inteiro?"
Sam said, "No, I didn't. I only wrote a unit test."Sam disse: "Não, eu não escrevi. Eu só escrevi um teste unitário."
Together they wrote an integration test that checked the order, the payment, and the email confirmation.Juntos, eles escreveram um teste de integração que verificava o pedido, o pagamento e a confirmação por e-mail.
The integration test failed because the email service returned a timeout.O teste de integração falhou porque o serviço de e-mail retornou um timeout.
Sam fixed the bug in the email step, ran the test again, and the test passed.Sam consertou o defeito na etapa de e-mail, executou o teste de novo e o teste passou.
At the end of the day, the test report showed 12 tests passed and 0 failed.No final do dia, o relatório de testes mostrou 12 testes que passaram e 0 que falharam.

Notas de vocabulário

  • unit test = teste que cobre uma função isolada; Sam escreveu um para addOrderItem.
  • Expected result / Actual result = o que o código deveria fazer vs. o que o código realmente fez.
  • test failed: function ... is missing = mensagem típica de um test report quando a função não existe.
  • the test passed = resultado igual ao esperado; usado como linha final do Result.
  • integration test = teste que cobre várias partes juntas; no texto, pedido + pagamento + e-mail.
  • test report = resumo com a lista de pass e fail no final da execução.

Perguntas de compreensão

  1. What did Sam decide to write before the function?
  2. Why did the first test fail?
  3. What was the expected result in Sam's test?
  4. Did Sam write an integration test at first?
  5. Why did the integration test fail?
  6. How many tests passed at the end of the day?

Prática com a história

  1. Transforme em frase de falha: The integration test passed.
  2. Complete: The test failed ___ the email service returned a timeout.
  3. Responda negativamente: Did Sam write an integration test at first?
  4. Escreva uma linha Result para um teste em que expected = 8 e actual = 8.

Prática

Exercícios e teste

Próxima etapa
6blocos de exercícios disponíveis neste tema
10questões de teste para revisar depois da aula

A próxima melhoria é transformar esses arquivos em perguntas com resposta no navegador. Por enquanto, esta página já organiza o estudo e permite seguir a aula inteira sem abrir os arquivos manualmente.