Skip to content

Commit f61d32d

Browse files
Add basic movement Automated Test and update Readme
1 parent 55a655b commit f61d32d

4 files changed

Lines changed: 68 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ CI workflow YAML files are included for Forgejo/Codeberg, GitHub and GitLab.
210210

211211

212212
## Automated Testing
213-
Provided Tests
213+
The provided tests can be run in an Action Workflow or run manually with RunUAT. Learn more about Unreal Engine Automated Testing in the [Run Automated Tests](dev.epicgames.com/documentation/unreal-engine/run-automation-tests-in-unreal-engine?lang=en-US) documentation.
214214

215-
TODO
215+
- `AlsxtTest_BasicMovement`
216216

217217
## Code Coverage
218-
OpenCodeCoverage will perform Code Coverage analysis and publish and XML file as a Commit Artifact, and can optionally be uploaded to a configured Codecov account. You will need to generate an Access Token from your Codecov account and add it the the workflow YAML files.
218+
OpenCodeCoverage will perform Code Coverage analysis and publish and XML file as a Commit Artifact, and can optionally be uploaded to a configured Codecov account. You will need to first generate an Access Token from your Codecov account and add it your Forgejo/Codeberg, GitHub or GitLab Secrets as `CODECOV_TOKEN`.
219219

220220
# Asset Source Files
221221

‎Source/ALSXT/ALSXT.Build.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public ALSXT(ReadOnlyTargetRules Target) : base(Target)
7979
"EngineSettings",
8080
"PhysicsCore",
8181
"Slate",
82-
"SlateCore",
82+
"SlateCore"
8383
]);
8484

8585
if (Target.Type == TargetRules.TargetType.Editor)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include "AlsxtTest_BasicMovement.h"
2+
#include "GameFramework/Character.h"
3+
#include "GameFramework/PlayerController.h"
4+
#include "Kismet/GameplayStatics.h"
5+
#include "Tests/AutomationCommon.h"
6+
7+
// Latent command to simulate holding "Forward" for a specific duration
8+
DEFINE_LATENT_AUTOMATION_COMMAND_THREE_PARAMETER(FAlsxtSimulateMoveForward, ACharacter*, Character, float, Duration, float, ElapsedTime);
9+
10+
bool FAlsxtSimulateMoveForward::Update()
11+
{
12+
float DeltaTime = FApp::GetDeltaTime();
13+
ElapsedTime += DeltaTime;
14+
15+
if (Character)
16+
{
17+
// ALSXT characters still use standard AddMovementInput for basic velocity
18+
Character->AddMovementInput(Character->GetActorForwardVector(), 1.0f);
19+
}
20+
21+
return ElapsedTime >= Duration;
22+
}
23+
24+
bool FAlsxtTest_BasicMovement::RunTest(const FString& Parameters)
25+
{
26+
// 1. Load a basic test level or use current
27+
AutomationOpenMap(TEXT("/Game/Maps/TestMap")); // Replace with your actual test map path
28+
29+
UWorld* World = GEngine->GetWorldContexts()[0].World();
30+
if (!World) return false;
31+
32+
// 2. Get or Spawn Character
33+
ACharacter* Character = UGameplayStatics::GetPlayerCharacter(World, 0);
34+
if (!Character) return false;
35+
36+
FVector StartLocation = Character->GetActorLocation();
37+
38+
// 3. Queue movement simulation (Latent command)
39+
ADD_LATENT_AUTOMATION_COMMAND(FAlsxtSimulateMoveForward(Character, 1.0f, 0.0f));
40+
41+
// 4. Verify movement after latent command finishes
42+
ADD_LATENT_AUTOMATION_COMMAND(FFunctionLatentCommand([this, Character, StartLocation]()
43+
{
44+
FVector EndLocation = Character->GetActorLocation();
45+
float DistanceMoved = FVector::Dist(StartLocation, EndLocation);
46+
47+
// Assert that the character moved at least 100 units forward
48+
TestTrue(TEXT("Character should have moved forward"), DistanceMoved > 100.0f);
49+
return true;
50+
}));
51+
52+
return true;
53+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "CoreMinimal.h"
4+
#include "Misc/AutomationTest.h"
5+
6+
/**
7+
* Basic automated test to verify ALSXT character can move forward.
8+
* Found in: Tools > Test Automation > Project.ALSXT.Movement.MoveForward
9+
*/
10+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FAlsxtTest_BasicMovement, "Project.ALSXT.Movement.MoveForward",
11+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ProductFilter)

0 commit comments

Comments
 (0)