1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package dev.aherscu.qa.testing.example.scenarios.tutorial1;
18
19 import static java.lang.Math.*;
20
21 import org.testng.annotations.*;
22
23 import edu.umd.cs.findbugs.annotations.*;
24 import lombok.*;
25 import lombok.extern.slf4j.*;
26
27 @Slf4j
28 public class PlainTestNg {
29 @Test
30 public void _1_shouldSucceed() {
31 assert true;
32 }
33
34 @Test(dataProvider = "_2_notTruthTable")
35 public void _2_checkNot(
36 final boolean argument,
37 final boolean result) {
38 log.debug("checking {} is not {}", argument, result);
39 assert argument != result;
40 }
41
42 @Test(dataProvider = "_3_fullAdderTruthTable")
43 public void _3_checkFullAdder(final FAT v) {
44 assert ((v.a || v.b) == v.sum)
45 && ((v.a && v.b) == v.carry);
46 }
47
48 @Test(dataProvider = "_4_sinusTruthTable")
49 public void _4_checkSinus(final double angle, final double sinus) {
50 assert sin(angle) == sinus;
51 }
52
53 @SuppressFBWarnings(
54 value = "UPM_UNCALLED_PRIVATE_METHOD",
55 justification = "called by testng framework")
56 @DataProvider(parallel = false)
57 private Object[][] _2_notTruthTable() {
58 return new Object[][] {
59 { false, true },
60 { true, false }
61 };
62 }
63
64 @SuppressFBWarnings(
65 value = "UPM_UNCALLED_PRIVATE_METHOD",
66 justification = "called by testng framework")
67 @DataProvider
68 private Object[][] _3_fullAdderTruthTable() {
69 return new Object[][] {
70
71 {FAT.builder().a(false).b(false).sum(false).carry(false).build()},
72 {FAT.builder().a(false).b(true) .sum(true) .carry(false).build()},
73 {FAT.builder().a(true) .b(false).sum(true) .carry(false).build()},
74 {FAT.builder().a(true) .b(true) .sum(true) .carry(true) .build()},
75
76 };
77 }
78
79 @SuppressFBWarnings(
80 value = "UPM_UNCALLED_PRIVATE_METHOD",
81 justification = "called by testng framework")
82 @DataProvider
83 private Object[][] _4_sinusTruthTable() {
84 return new Object[][] {
85
86
87 { 0, 0 },
88
89 { PI / 2, 1 },
90 { 1.5 * PI, -1 },
91
92
93 };
94 }
95
96 @Builder
97 @ToString
98 static class FAT {
99 final boolean a, b, sum, carry;
100 }
101 }