0

I am new to unit testing.
I am trying to perform unit testing on the below code

public void send(Map<String, List<Integer>> mapOf){

     mapOf.forEach((k ,v) -> {
         v.stream().forEach(o ->{
             myList.add(o)
             message.push(o);
         });
     });
    }


message.push(o), pushes data to the database. <br/>


How can I Unit test this method?

mayank bisht
  • 618
  • 3
  • 14
  • 43
  • I do not fully understand your example: What is myList used for? Is the code just writing all Integers to the data base, with the keys being ignored? And, why do you mention coverage in your question? – Dirk Herrmann Feb 13 '19 at 21:37

1 Answers1

1

I would Mock this message obejct and Verify how mamy times it was called .

More informations and example you can find here

Same problem

Emil Hotkowski
  • 2,233
  • 1
  • 13
  • 19