I have a class I want to test that has an associated test class with it. I am wondering if I use a TestDataFactory class if the @TestSetup annotation will allow me to access the data inserted from my test class
public class FunctionalClass {
//logic that needs to be tested
}
@IsTest
public class TestFunctionalClass {
//unit tests that test FunctionClass logic
//query for data that is setup in TestDataFactory.class
}
@IsTest
public class TestDataFactory {
@TestSetup
static void setup() {
//insert test data
}
public static List<ExternalObject__x> getExternalObjectTestData() {
//return mock external objects
}
}
I know I can just have the setup method in my TestFunctionalClass but I'd like for all test data to be in my DataFactory class.