我有恩Platform.getBundle(Activator.PLUGIN_ID)返回null
public void func {
....
....
URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry("config");
....
....
}
现在我写的JUnit测试案例上述功能,该功能在不同的测试插件的功能。 当我在我的junit测试方法中调用func时,我收到空指针异常。
我试着打印
Platform.getBundle(Activator.PLUGIN_ID) which returns null
Platform.isRunning() which returns false.
请让我知道如何解决这个问题?我可以做什么,以便我的JUnit测试用例成功。
预先感谢您。
可以移动Platform.getBundle(Activator.PLUGIN_ID)的方法和存根方法为您的测试 –
你能否更详细的吧。我对存根和嘲笑很陌生。我不知道如何存根。逻辑代码会有所帮助。 – user2179627
基本上将您的“Platform.getBundle(Activator.PLUGIN_ID)”移动到方法并在测试期间使用ovverride方法 –