[英]How do I test an interface that has no implementation
I have an interface and its implementation. 我有一个接口及其实现。 I'm working on a plugin for JIRA.
我正在为JIRA开发插件。 I've just decided on its design but do not have implementation as such.
我刚刚决定了它的设计,但是没有这样的实现。 I'm kinda lost on how to test it when it has no methods in it.
当它没有方法时,我有点不知道如何进行测试。 Can anyone pls help?
有人可以帮忙吗? thanks..
谢谢..
package com.cerner.jira.plugins.esig.servicemanager;
import java.util.List;
import com.atlassian.jira.issue.Issue;
import com.cerner.jira.plugins.esig.issuetab.*;
public interface EsignatureManager {
public List<EsignatureTabPanelData> getElectronicSignatures(Issue paramIssue);
}
and I have a class that implements this... 我有一个实现这个的类...
package com.cerner.jira.plugins.esig.
import java.util.List;
import com.cerner.jira.plugins.esig.customfields.UnameCustomField;
import com.atlassian.jira.issue.Issue;
import com.cerner.jira.plugins.esig.issuetab.EsignatureTabPanelData;
public class EsignatureManagerImpl implements EsignatureManager {
UnameCustomField unamecustomfield;
@Override
public List<EsignatureTabPanelData> getElectronicSignatures(Issue paramIssue) {
return null;
}
}
An interface cannot be tested as well as if it compiles it makes all the functions that it should do. 无法对接口进行测试,也不能对其进行编译,因为它可以完成它应该执行的所有功能。 You can't test something that do nothing, that is the case of an interface.
您不能测试无所事事,例如接口。
Test the class that implements the interface. 测试实现接口的类。 If you are doing test driven development, write the test to look for what you expect your getElectroniceSignatures to return, possibly a non-empty list of the type you specified?
如果您正在执行测试驱动的开发,请编写测试以查找期望getElectroniceSignatures返回的内容,可能是指定类型的非空列表? If you are not, then go ahead and implement the interface member in the class first, then write a test method for the classes implementation of the interface member once you have it doing what you expect.
如果不是,那么请继续并首先在类中实现接口成员,然后在完成预期的工作后为接口成员的类实现编写测试方法。
I guess you could start it off with something like this and change your test as you know more about your methods. 我猜您可以从这样的事情开始,并随着对方法的更多了解来更改测试。
@Test
public void getElectronicSignatures(){
fail("Not implemented yet");
}
我不知道这是否是您特定(JIRA特定)用例的答案,但是:可以测试一个接口:您可以使用反射来检查该接口是否提供了特定的方法,注释等。(但是我假设您是指JIRA中的“测试”?)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.