Here's the situation. I have TestA class that creates the object of type A that needs to be tested. I also have another TestB class that contains static variable that is object of type B and runs tests on it. Testing on object A will only run if object B exists, so I currently have situation like this somwehere in TestA class:
if(BTest.objectB == null) {
new TestB().dependencyBuild();
}
And this works. I don't wanna waste time on explaining why, but I need this snippet of code to also work if I only have the Strings with names of TestB class and objectB (or any other class my test is dependent on) given to me as arguments. I need to turn those strings into parent class and parent object variables so the above snippet rewriten like this would work:
if(ParentClass.parentObject == null) {
new ParentClass().dependencyBuild();
}
Is something like this possible? I've already tried to use the answers here: Creating an instance using the class name and calling constructor but I don't know how to make it work when a) other class (TestB) doesn't have a constructor and b) variable I need (objectB) is static.