I was trying to get have a setup() and teardown() function for my FAutomationTestBase, but it doesn’t have it. So that makes that I need to implement it myself everytime like so:
IMPLEMENT_SIMPLE_AUTOMATION_TEST(MyTest_DoesNothing, "MyProject.MyTest.DoesNothing", EAutomationTestFlags::EngineFilter | EAutomationTestFlags::EditorContext)
bool MyTest_DoesNothing::RunTest(const FString& Params)
{
MyTestUtil::setup();
// do an actual test
MyTestUtil::teardown();
}
This will become more and more and I know I want to use the same setup everytime. I’d like to see an optional setup() and teardown() function and implement it with IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST as such:
class MyTestBase : public FAutomationTestBase
{
protected:
void setup() override
{
// do setup stuff
}
void teardown() override
{
// do teardown stuff
}
}
IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST(MyTest_DoesNothing, MyTestBase, "MyProject.MyTest.DoesNothing", EAutomationTestFlags::EngineFilter | EAutomationTestFlags::EditorContext)
bool MyTest_DoesNothing::RunTest(const FString& Params)
{
// do an actual test
}
I see this a lot in other test frameworks, like NUnit and I really like this way of working.