Automated Testing architecture?

Hello!

I’m a Unity developer new to Unreal and I want to make my code “ready” for automated testing to begin with, to not run into problems later.
I am aware of the Humble Object pattern, but the setup requires lots of classes at different places, which is why I’d love to hear what the most practically solution might be.
Let me list the solutions I have in my head:

Solution 1: Do not abstract logic and Actor classes at all. Issues: Some functions trigger animations that need to be completed to continue (unit testing needs to go around them), + lots of potential issues with the UE4 classes? Would be most straight forward to code through.

Solution 2: Classic Humble Object pattern:

class IFoo
{
     virtual void doUeStuff() = 0;
};

class AFoo : public IFoo
{
     void doUeStuff() override
     {
          // Actually do it
     }
};

class MockFoo : public IFoo
{
     void doUeStuff() override
     {
         return;
     }
};

class FooController
{
    IFoo* foo;
  
   void doStuff()
   {
     foo->doUeStuff();
   }

}

Issues: Lots of code for 1 class. Also, is this Blueprint friendly?

Solution 3: Provide NULL pointer to foo in FooController in test. Instead of declaring the interface + implementing a mock class, the pointer just gets checked for NULL. Issues: Overhead with the “if (foo)” check every time? But very handy IMO.

I’m a bit unsure what the best layout is to use, also does UE4 provide any kind of mock framework? Should I worry about automated testing at all before actively pursuing it? I’m still at the stage where I set everything up which is why I want to have a test friendly architecture instead of just putting down code.

Hi, wouldn’t it be better to just do TDD in your case? You would be creating the architecture based on testing.
As for the solutions, I think the best way is the first solution because is the one that it doesn’t get in your way.

With TDD, the approach would be simple: you first create the test, check that the test fails and THEN you code the class to only fullfil the test.

I’m pretty sure UE4 doesn’t have a mock framework.

If you’re interested in some practical tests examples, I wrote a wiki to make a simple CI environment for UE4 using Jenkins In there, I link a GitHub repository with some tests.

The automation documentation in the official UE4 page is poor. Luckily there’s an automation subchannel inside unrealSlackers were your question will have more answers ;).