dimanche 4 octobre 2020

How to perform JUnit testing on a class that uses interfaces not yet implemented as method parameters?

I can't figure out how to perform Junit testing on a class that uses an interface not yet implemented as method parameters. I don't know the implementation of the interface so i can't implement it.

For example I have this interface

public interface Command{
     public void execute();
     ....
} 

and class that uses the interface as method parameters.

public class Manager{
    List<Command> listCommands = new List<Command>();

    public void storeCommand(Command command){
       listCommands.add(command);
    }
}

I read online one solution could be to use mockito to mock the implementation of the interfaces but i'm not sure.

Thanks!

Aucun commentaire:

Enregistrer un commentaire