-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertivasTest.java
More file actions
80 lines (66 loc) · 2.24 KB
/
AssertivasTest.java
File metadata and controls
80 lines (66 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package br.edu.ifpe.jaboatao.ts.servicos;
import static org.junit.jupiter.api.Assertions.assertAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import br.edu.ifpe.jaboatao.ts.entidades.Cliente;
//mostrar o texto no junit
@DisplayName("Testando assertivas")
public class AssertivasTest {
@Test
// mostrar o texto no junit
@DisplayName("teste assertTrue e assertFalse")
public void teste1() {
// testa se é verdadeiro
Assertions.assertTrue(true);
// testa se é falso
Assertions.assertFalse(false);
}
@Test
// mostrar o texto no junit
@DisplayName("teste assertEquals")
public void teste2() {
// assertEqual para testar se o valor espectativa é igual ao atual
// funciona com texto e numeros
// colocar um texto do lado é para caso der erro e apareça a mensagem
Assertions.assertEquals(1, 1, "o valor deveria igual a 1");
Assertions.assertEquals("teste", "teste");
Cliente cliente1 = new Cliente("cliente 1");
Cliente cliente2 = new Cliente("cliente 1");
Assertions.assertEquals(cliente1, cliente2);
// com o ignoreCase
Assertions.assertTrue("Teste".equalsIgnoreCase("teste"));
}
@Test
// mostrar o texto no junit
@DisplayName("teste assertSame")
public void teste4() {
Cliente cliente1 = new Cliente("cliente 1");
Cliente cliente2 = cliente1;
// apenas com a mesma instancia
Assertions.assertSame(cliente1, cliente2);
}
@Test
// mostrar o texto no junit
@DisplayName("teste assertNull")
public void teste5() {
Cliente cliente1 = null;
Cliente cliente2 = new Cliente("cliente 1");
// caso seja null entrega verdadeiro
Assertions.assertNull(cliente1);
// se não for nulo entrega verdadeiro
// o "not" é a negação, serve para todos
Assertions.assertNotNull(cliente2);
}
@Test
// mostrar o texto no junit
@DisplayName("teste assertAll")
public void teste6() {
//para verificas todos os erros listados
Assertions.assertAll(
() -> Assertions.assertEquals("teste", "teste", "é esperado teste"),
() -> Assertions.assertEquals(1, 1, "é esperado um valor igual a 1"),
() -> Assertions.assertTrue(true, "é esperado true")
);
}
}