How can i test an interface?

前端 未结 4 469
刺人心
刺人心 2021-01-07 09:13

I want to do a JUnit test case for an interface, as you know i can\'t make an object from the interface and i don\'t want any classes names to show up in that test, i want o

4条回答
  •  隐瞒了意图╮
    2021-01-07 09:30

    You could make an abstract base class for unit tests. For specific classes that implement the interface a unit test would simply extend the abstract base class.

    The abstract base class could test things that should hold, like close after open or other things.

提交回复
热议问题