FAutomationTestBase could use a setup and teardown function

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.

Hey mtass!

This does make a lot of sense, I’m unsure where you’re question is here, though.

Also, keep in mind, that with “LatentCommands”, teardown will potentially be called before the test is actually complete!
You should therefore create a TeardownLatentCommand, which calls the teardown code as the final LatentCommand in the queue, and add that command at the end of the test.

Cheers,

Hi , I remember that I also have to put feature requests on this forum here, so that’s why I posted the question. I hope that the Unreal team will pick it up.