I have following class structure:
--------------------------------------------------------------------------------------------------
public class A {
@Factory
public Object[] tst_createFactoryTests() {
}
}
public class B extends A {
public static final int NUM = 10;
}
public class C extends A {
public static final int NUM = 20;
}
public class D extends A {
public static final int NUM = -30;
}
--------------------------------------------------------------------------------------------------
- So basically class A is a super class. And class B, C & D extend class A.
- I am writing a factory method in class A which should create a test for each of the class which extends it only if the value of NUM is positive for the class invoking the superclass.
- So every time when class A is invoked by one of the subclasses (B or C), the factory method in class A should create tests for those test classes (One for class B and one for class C).
- And in case when class A is invoked by class C, since the NUM value is negative, the factory method should skip creation of test for class C.
- While doing so, I am getting following exception:
- An error occurred while instantiating class A. Check to make sure it can be instantiated. Root cause: The Factory method tst_createFactoryTests() should have produced at-least one instance.
- So, my question is do we have a way by which we can skip instantiation of a factory method for a few cases based on a condition?
- Please let me know if the question is not clear or if I need to add some more information about it.
Thanks in advance!!