I am currently in the process of refactoring all my game code, and I wanted to add Automated tests to my project so that I could add new features to my code without having to worry about old features breaking without my knowledge. I wrote a very basic test just for trying to get the hang of using the Automation tool, but the problem is that I can’t seem to find my test in the Automation tool and I can’t seem to find any documentation on how to run my test once I’ve written it.
I’m not getting any build errors and at this point I’m not sure if I’m using the tool wrong, or if there is some way to register my test that I am not aware of, but so far I can’t seem to make my test visible within the automation tool. I’ve been looking over the documentation, but I can’t seem to find much on creating or running tests. I based my test off the ones in TimespanTest.cpp and EngineAutomationTests.cpp, of which most I can find in the automation tool. If anyone could help me figure out what I need to do or am doing wrong, I would be very grateful.
Update: I found a function called RegisterAutomatedTest in FAutomationTestFrameWork. From the description it sounds like this should add my test to the list of tests that can be found from within the automation tool. I’ll try using it in my test project and report back if it works.
Following my last update, looking into AutomationTest.h, it appears that one’s test should registered when using the IMPLEMENT_SIMPLE_AUTOMATION_TEST macro, since the constructor of the base class the implemented test class is a child of registers the test with the above mentioned RegisterAutomatedTest function. I’m going to try and see if that constructor is actually being called by my custom test and I’ll report back my findings.
Like I thought the constructor is definitely being called, as is RegisterAutomatedTest. Still not sure why my test isn’t showing up in the Automated Test Tool.
I found the function LoadTestModules from within FAutomationFramework, and the description in documentation says that it loads modules that aren’t loading by default that contain tests. I don’t think it will accomplish what I am trying to do, but I figure it’s worth trying at this point, so I am going to run this function in BeginPlay from the game mode of the map I am testing and I’ll see if that makes a difference and report back.
I got somewhere by changing the flag ATF_Game to ATF_Editor, unfortunately, even though doing so made my test appear in the editor, it also made it trigger a breakpoint when I tried to run it, despite there being an instance of the game open in PIE mode. Going to try messing around with the flags a bit and see if I can’t get the test to load the level in question before trying to execute the rest of the test code.
I am going to try running the front end on it’s own and see if I can’t test the game in standalone mode with the standalone front end since I can’t seem to get it working with the in editor front end, which only show me the editor session.
So now I am trying to build the game in the development build config and we’ll see if that shows up in the Frontend
So I was able to run the test by packaging the game and starting it in the Frontend Tool, but the game instance just closed when I tried to run the test. I got a message saying that the tool was not able to run successfully in the log, but nothing else.
So I still haven’t gotten my test working exactly how I want it to, but I have successfully run a test both in game, and in editor, so I am going to count this as answered. When I figure out the rest of the automated test tools quirks I will post a guide on how everything works.