Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulo 4 - Stub, Mock e Spy #2

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open

Commits on Nov 24, 2023

  1. Configuration menu
    Copy the full SHA
    a621a88 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0407c99 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0936498 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    95b5e33 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    12dfeda View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8255211 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    644247e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ae4ffeb View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    f33d8cd View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d7b7a88 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    2b56d9a View commit details
    Browse the repository at this point in the history
  12. 2.4. Asserções de Exceptions: Comparar Mensagem passada, agora método…

    … conta com duas asserções.
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    fd90773 View commit details
    Browse the repository at this point in the history
  13. 2.4. Asserções de Exceptions:

    -método quando Exception não é lançada:
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    e0de01f View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    1f47e1c View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    9f7bf6f View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    4fe256f View commit details
    Browse the repository at this point in the history
  17. 2.6. Asserções de Timeout, é utilizado em métodos que demoram em sua …

    …asserção, porque ocorre falha caso o método demore muito para ser executado, usado para não bloquear o processo de build.
    
    problema desse método é que fica bloqueado por 10 segundos.
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    769bfff View commit details
    Browse the repository at this point in the history
  18. 2.6. Asserções de Timeout, é utilizado em métodos que demoram em sua …

    …asserção, porque ocorre falha caso o método demore muito para ser executado, usado para não bloquear o processo de build.
    
    Esse é o melhor método para validar o tempo de executação, porque não deixa bloqueado por 10 segundos chegou no 1 segundo conforme foi configurado já lança o erro de teste
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    ef3da1a View commit details
    Browse the repository at this point in the history
  19. 2.7. Asserções agrupadas com AssertAll: [Exemplo lançando erro]

    -Se o primeiro método falhar para e o resto das outras asserções não serão executadas.
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    877c5e8 View commit details
    Browse the repository at this point in the history
  20. 2.7. Asserções agrupadas com AssertAll: [Exemplo correto]

    -Se o primeiro método falhar para e o resto das outras asserções não serão executadas.
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    cf23cd0 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    94c9bd8 View commit details
    Browse the repository at this point in the history
  22. atualizando classe PessoaTest

    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    0e0764e View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    44cad1f View commit details
    Browse the repository at this point in the history
  24. 2.10. Ignorando execução dos testes condicionalmente com Assumptions …

    …existe duas formas:
    
    1º) Criando variável de ambiente dentro do profile e adicionando o Assumptions.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    d8c60e2 View commit details
    Browse the repository at this point in the history
  25. 2.10. Ignorando execução dos testes condicionalmente com Assumptions …

    …existe duas formas:
    
    2º) Criando variável de ambiente dentro do profile e adicionando o @EnabledIfEnvironmentVariable(named = "ENV", matches = "DEV")
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    b93c180 View commit details
    Browse the repository at this point in the history
  26. 2.11. Executando testes via Maven: adicionando plugin pom.xml para ex…

    …ecutar testes via terminarl -
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    1c338ea View commit details
    Browse the repository at this point in the history
  27. 2.11. ajustes na nomenclatura não aceita acentuação.

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    823b7be View commit details
    Browse the repository at this point in the history
  28. 2.11. Executando testes via Maven:

    Desabilitando a execução de teste via maven.
    
    Windows
    `mvn clean package '-Dmaven.test.skip=true'`
    
    Linux
    `mvn clean package -Dmaven.test.skip=true'
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    a90dc1d View commit details
    Browse the repository at this point in the history
  29. 2.12. Desafio - Escrevendo testes faltantes do SaudacaoUtil, como imp…

    …lementei.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    a631092 View commit details
    Browse the repository at this point in the history
  30. ajustar importes

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 24, 2023
    Configuration menu
    Copy the full SHA
    069dc96 View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2023

  1. 2.13. Refatorando classe SaudacaoUtil

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    f3baded View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2023

  1. 2.13. Refatorando classe SaudacaoUtil

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    23565b1 View commit details
    Browse the repository at this point in the history
  2. 2.13. Refatorando classe SaudacaoUtil

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    3a3aecd View commit details
    Browse the repository at this point in the history
  3. 2.13. Refatorando classe SaudacaoUtil

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    6b12f06 View commit details
    Browse the repository at this point in the history
  4. 2.13. Refatorando classe SaudacaoUtil

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    b1961eb View commit details
    Browse the repository at this point in the history
  5. 3.1. Organizando testes com o padrão Triple A: apenas adicionando com…

    …entário para facilitar o entendimento do padrão `Triple A`.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    36ed50b View commit details
    Browse the repository at this point in the history
  6. 3.1. Organizando testes com o padrão Triple A

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    76e3163 View commit details
    Browse the repository at this point in the history
  7. 3.2. Alterando nome de exibição dos testes com @DisplayName, tanto na…

    … classe como no método.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    7f6b2cf View commit details
    Browse the repository at this point in the history
  8. 3.3. Formatando nomes de testes com @DisplayNameGeneration

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    644dedf View commit details
    Browse the repository at this point in the history
  9. 3.4. Aplicando a nomenclatura do BDD para nomear métodos de teste

    Nomenclatura BDD:
    Dado__..Quando__..Entao
    
    -Given = Dado
    -When = Quando
    -Then = Então
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    cc8e8f8 View commit details
    Browse the repository at this point in the history
  10. 3.5. Organizando classe de testes com sub-classes e @nested

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    cf83f29 View commit details
    Browse the repository at this point in the history
  11. 3.6. Preparando o cenário de testes com @beforeeach e @BeforeAll, usa…

    …ndo com cenário de teste que precisam de depenências de classes.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    e50f51b View commit details
    Browse the repository at this point in the history
  12. 3.6. Preparando o cenário de testes com @beforeeach e @BeforeAll, usa…

    …ndo com cenário de teste que precisam de depenências de classes.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 28, 2023
    Configuration menu
    Copy the full SHA
    57352c5 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2023

  1. 3.7. Um teste deve ter uma única asserção?

    Sim deve ser refatorado para ter apenas uma asserção, é uma boa prática.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    d92ee1a View commit details
    Browse the repository at this point in the history
  2. 3.8. Combinando @nested e @beforeeach com a nomenclatura do BDD

    Exemplo Top!
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    429e92b View commit details
    Browse the repository at this point in the history
  3. 3.8. Combinando @nested e @beforeeach com a nomenclatura do BDD

    Exemplo Top!
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    8708f06 View commit details
    Browse the repository at this point in the history
  4. 3.9. Desafio - Implemente a lógica e testes de um carrinho de compras:

    [Cenário]-Dado um carrinho de compra com 2 tipos de itens e quantidade 3
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    6d84bb0 View commit details
    Browse the repository at this point in the history
  5. 3.9. Desafio - Implemente a lógica e testes de um carrinho de compras:

    [Cenário]-Dado um carrinho de compra com 0 itens
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    fb9f890 View commit details
    Browse the repository at this point in the history
  6. 3.9. Desafio - Implemente a lógica e testes de um carrinho de compras:

    [Cenário]-Dado um carrinho de compra com 2 tipos de itens e quantidade 3
    -> Remover produto carrinho
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    14eb8a2 View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2023

  1. 3.9. Desafio - Arquivo com resolução.

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 1, 2023
    Configuration menu
    Copy the full SHA
    a6c0516 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #1 from leco123/MODULO-3

    Modulo 3 - Organizando testes unitários
    leco123 authored Dec 1, 2023
    Configuration menu
    Copy the full SHA
    f13ecd1 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2023

  1. 3.9. Desafio - Arquivo com resolução.

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    15f1130 View commit details
    Browse the repository at this point in the history
  2. 3.9. Desafio - Arquivo com resolução.

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    461dec2 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2023

  1. Merge pull request #2 from leco123/MODULO-3

    Modulo 3
    leco123 authored Dec 9, 2023
    Configuration menu
    Copy the full SHA
    1b4d2dd View commit details
    Browse the repository at this point in the history
  2. MÓDULO-4: Stub, Mock e Spy

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    c236cbc View commit details
    Browse the repository at this point in the history
  3. 4.1. Implementações falsas com Stub

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 9, 2023
    Configuration menu
    Copy the full SHA
    e38b73c View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2023

  1. 4.2. Introdução ao Mock + 4.3. Simulando classes com Mockito

    -Adicionado Dependência do Mockito.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    673fd04 View commit details
    Browse the repository at this point in the history
  2. 4.2. Introdução ao Mock + 4.3. Simulando classes com Mockito

    -Adicionado Dependência do Mockito.
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    8c4d6bd View commit details
    Browse the repository at this point in the history
  3. 4.2. Introdução ao Mock + 4.3. Simulando classes com Mockito

    -Renomeando arquivos
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    9b532fb View commit details
    Browse the repository at this point in the history
  4. 4.2. Introdução ao Mock + 4.3. Simulando classes com Mockito

    -Criando Mock:
     -> 1º) Deve ser instanciado e criado um mock para classe;
     -> 2º) Precisa definir comportamento do mock;
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    68cfab3 View commit details
    Browse the repository at this point in the history
  5. 4.4. Mock usando annotations

    Extensão do Mockito para o próprio JUnit
    -`@ExtendWith(MockitoExtension.class)`
    -`@Mock`
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    9410636 View commit details
    Browse the repository at this point in the history
  6. 4.5. Alterando estado dos parâmetros passados no mock

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 14, 2023
    Configuration menu
    Copy the full SHA
    63f39ac View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2023

  1. 4.6. Parâmetros dinâmicos

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    5c1b46a View commit details
    Browse the repository at this point in the history
  2. 4.7. Verificando chamada de métodos com mock usando Mockito verify

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    134fef3 View commit details
    Browse the repository at this point in the history
  3. 4.7. Verificando chamada de métodos com mock usando Mockito verify

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    f50d504 View commit details
    Browse the repository at this point in the history
  4. 4.8. Forçando uma Exception com mock

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 20, 2023
    Configuration menu
    Copy the full SHA
    900a59a View commit details
    Browse the repository at this point in the history

Commits on Dec 21, 2023

  1. 4.8. Forçando uma Exception com mock

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Dec 21, 2023
    Configuration menu
    Copy the full SHA
    20368c5 View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2024

  1. 4.8. Forçando uma Exception com mock

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    45df9bb View commit details
    Browse the repository at this point in the history
  2. 4.9. Capturando parâmetros enviados aos mocks com Argument Captor

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    48d9571 View commit details
    Browse the repository at this point in the history
  3. 4.10. Espionando um objeto real com Mockito

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    af7d21c View commit details
    Browse the repository at this point in the history
  4. 4.11. Alterando retorno de um mock após chamadas consecutivas

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    39688a4 View commit details
    Browse the repository at this point in the history
  5. 4.11. Alterando retorno de um mock após chamadas consecutivas

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    8d82194 View commit details
    Browse the repository at this point in the history
  6. 4.12. Verificando ordem de chamada de métodos

    -Dos nossos mocks;
    
    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    b2c922c View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2024

  1. 4.13. Usando mock em métodos estáticos

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    d8ee13c View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2024

  1. 4.14. Entendendo problema de mocks não utilizados

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 21, 2024
    Configuration menu
    Copy the full SHA
    616f4c8 View commit details
    Browse the repository at this point in the history
  2. 4.15. Implementando testes no CadastroEditor no método de edição

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 21, 2024
    Configuration menu
    Copy the full SHA
    76ee00c View commit details
    Browse the repository at this point in the history
  3. 4.16. Desafio - Criar testes do CadastroPost

    Signed-off-by: Alex de Carvalho <[email protected]>
    leco123 committed Jan 21, 2024
    Configuration menu
    Copy the full SHA
    f814f81 View commit details
    Browse the repository at this point in the history