Topic:   How to mock Scanner to use in junit test?
Mar 29, 2021 12:24 1 Replies 392 Views RANJIT

How to mock Scanner to use in junit test?

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    SANJAY

    public int chooseValue(Scanner in){
    int option;
    System.out.printl("Choose number. 0 to 3:");
    escolha = in.nextInt();
    return option;
    }
    How to do a test for this method.
    ANS. Scanner implements Iterator so use that.

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect