Just a Pseudo Code...
private Platform platform;
public void func() {
//....
//....
URL url = getPlatForm().getEntry("config");
//....
//....
}
public Platform getPlatForm() {
return platform.getBundle(Activator.PLUGIN_ID);
}
In your testcase,
override the getPlatForm() method with a mock/stub.
Class yourClass = new yourClass() {
@override
public Platform getPlatForm() {
return mock/stub!!;
}
}
Platform.getBundle(Activator.PLUGIN_ID) returns null
Question
I have a function for ex
public void func {
....
....
URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry("config");
....
....
}
Now I am writing Junit test case for the above function which is in different test plugin. When I call func in my junit test method I am getting null pointer exception.
I tried printing
Platform.getBundle(Activator.PLUGIN_ID) which returns null
Platform.isRunning() which returns false.
Please let me know how to solve this? What I can do so that my JUnit testcase is successful.
Thank you in advance.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow