Skip to content

Commit

Permalink
Add: Functional Test
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Dec 10, 2023
1 parent f83230f commit 12d9d1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public FunctionalTest(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string[]{"Core", "CoreUObject", "Engine", "InputCore"});
PublicDependencyModuleNames.AddRange(new string[]{"Core", "CoreUObject", "Engine", "InputCore", "BlueprintToRSTDoc"});

PrivateDependencyModuleNames.AddRange(new string[]{});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,17 @@
* https://opensource.org/licenses/MIT
*/

#include "Engine/Blueprint.h"
#include "Engine/Engine.h"
#include "Engine/World.h"
#include "GameFramework/Actor.h"
#include "Misc/AutomationTest.h"
#include "Kismet/KismetSystemLibrary.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FFuntionalTestSyncVersion, "Kdtree.FunctionalTest.SyncVersion",
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter);

bool TestCommon(FAutomationTestBase* AuctionmationTest, UBlueprint* Blueprint)
{
AuctionmationTest->TestNotNull(TEXT("Blueprint should not be null"), Blueprint);

UClass* GeneratedClass = Blueprint->GeneratedClass;
UWorld* World = GEngine->GetWorldContexts()[0].World();
AActor* Actor = World->SpawnActor<AActor>(GeneratedClass);
AuctionmationTest->TestNotNull(TEXT("Actor should not be null"), Actor);
#include "BPLibrary.h"

for (TFieldIterator<UFunction> It(GeneratedClass); It; ++It)
{
UFunction* Function = *It;
if (Function->GetFName().ToString().StartsWith("Test_"))
{
struct FParameters
{
int32 ReturnValue = 0;
};
int32 Expect = 1;
FParameters Params;
Actor->ProcessEvent(Function, &Params);
AuctionmationTest->AddInfo(FString::Format(TEXT("Run '{0}'"), {Function->GetFName().ToString()}));
AuctionmationTest->TestEqual(TEXT("The return value is incorrect"), Params.ReturnValue, Expect);
}
}

return true;
}
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FFuntionalTestSyncVersion, "BlueprintToRSTDoc.FunctionalTest.GenerateRSTDocument",
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter);

bool FFuntionalTestSyncVersion::RunTest(const FString& Parameters)
{
UBlueprint* Blueprint = LoadObject<UBlueprint>(nullptr, TEXT("/Game/FunctionalTest/SyncVersion.SyncVersion"));
UBlueprintToRSTDocBPLibrary::GenerateRSTDoc();

return TestCommon(this, Blueprint);
return 0;
}

0 comments on commit 12d9d1f

Please sign in to comment.