1
+ import java .util .HashMap ;
2
+
3
+ public class PruebasJUNIT {
4
+ HashMap <String , String > map = new HashMap <>();
5
+
6
+ public int sumar (int num1 , int num2 ) {
7
+ return num1 + num2 ;
8
+ }
9
+
10
+ public void setMap () {
11
+ map .put ("name" , "Michael" );
12
+ map .put ("age" , "31" );
13
+ map .put ("birth_date" , "06/02/1993" );
14
+ map .put ("programming_languages" , "JAVA" );
15
+ }
16
+ }
17
+
18
+ // TESTS
19
+
20
+ import org .junit .Before ;
21
+ import org .junit .Test ;
22
+
23
+ import static org .junit .Assert .assertEquals ;
24
+ import static org .junit .Assert .assertTrue ;
25
+
26
+ public class TestJUNIT {
27
+ private PruebasJUNIT pruebasJUNIT ;
28
+
29
+ @ Before
30
+ public void setUp () {
31
+ pruebasJUNIT = new PruebasJUNIT ();
32
+ pruebasJUNIT .setMap ();
33
+ }
34
+
35
+ @ Test
36
+ public void testSum () {
37
+ assertEquals (5 , pruebasJUNIT .sumar (2 , 3 ));
38
+ }
39
+
40
+ @ Test
41
+ public void testMapKeys () {
42
+ assertTrue (pruebasJUNIT .map .containsKey ("name" ));
43
+ assertTrue (pruebasJUNIT .map .containsKey ("age" ));
44
+ assertTrue (pruebasJUNIT .map .containsKey ("birth_date" ));
45
+ assertTrue (pruebasJUNIT .map .containsKey ("programming_languages" ));
46
+ }
47
+
48
+ @ Test
49
+ public void testMapValues () {
50
+ assertTrue (pruebasJUNIT .map .containsValue ("Michael" ));
51
+ assertTrue (pruebasJUNIT .map .containsValue ("31" ));
52
+ assertTrue (pruebasJUNIT .map .containsValue ("06/02/1993" ));
53
+ assertTrue (pruebasJUNIT .map .containsValue ("JAVA" ));
54
+ }
55
+ }
0 commit comments