DaedalicEntertainment / ue4-test-automation

Facilitates setting up integration test suits with Unreal Engine 4 Gauntlet.
https://www.daedalic.com
MIT License
215 stars 62 forks source link

Debug GauntletTestController from VisualStudio #41

Open realfleo opened 1 year ago

realfleo commented 1 year ago

Hi great framework, many thanks. Can you explain how to debug a GauntletTestController from VisualStudio? I want to do some modification and don't know how to attach when running from console.

Something like that, maybe? https://docs.unrealengine.com/4.26/en-US/ProductionPipelines/BuildTools/AutomationTool/Overview/

Many thanks!

PanPandzik commented 1 year ago

So it's a little bit complicated. For first, sorry for my English, it's not my native language - just ask if something will be confusing.

There are two command-line arguments that let you "pause" the game on initialization: "-WaitForDebugger" and "-waitforattach". It's easy if you just run a game, because in that case you run a game with launch parameters, e.g.

MyGame.exe -waitforattach

But you have to run your game with Gauntlet via UAT, so use a command-line, like that:

"C:\Workspace\MayhemWorkspace\Engine\Build\BatchFiles\RunUAT.bat" RunUnreal -project="C:\Workspace\MayhemWorkspace\Mayhem\Mayhem.uproject" -scriptdir="C:\Workspace\MayhemWorkspace\Mayhem" -platform=Win64 -configuration=Development -WaitForDebugger -build=local -test="AnsharTests.Automation.SmokeTest"

So… if you add "-waitforattach" here, nothing will happen. I don't know why, but probably UAT doesn't pass the argument or does it but too late? I use a workaround for that, and I add this argument to the command-line in automation project script of my test (C# UnrealTestNode). In the case of the Daedalic plugin it will be DaeGauntletTest.cs in DaedalicTestAutomationPlugin.Automation project.

        public override SmokeTestConfig GetConfiguration()
        {
            SmokeTestConfig Config = base.GetConfiguration();
            UnrealTestRole ClientRole = Config.RequireRole(UnrealTargetRole.Client);

            ClientRole.CommandLine += "-waitforattach";

            return Config;
        }

So, if you did it, then you can run the game with gauntlet and attach your VS debugger to the process (Debug -> Attach to Process). If -waitforattach was passed correctly, then game window probably don't show up until you attach debugger, or it will be just black screen, so don't worry. If you still can't catch the breakpoint inside your Gauntlet Controller, for first, make sure your automation project use a right controller. Also, you can turn off "Enable Just My Code" option. image