gpt4 book ai didi

java - 我应该如何测试接口(interface)?

转载 作者:行者123 更新时间:2023-11-28 21:30:47 25 4
gpt4 key购买 nike

我有两个非常简单的界面

public interface Decoder {
public void decode() throws Exception;
}


public interface Encoder {
public void Encode() throws Exception;
}

如何使用 mockito 测试这两个接口(interface)?

最佳答案

正如 Jeroen 在评论中提到的:

What do you want to test? There is nothing to test with an interface.

相反:

You have to test the implementations of your interfaces. Or test the classes that have a field of type Decoder/Encoder and mock these interfaces. But not the interface itself, that doesn't make sense.

关于java - 我应该如何测试接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23185638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com