自动化测试不会显示在会话前端中。虚幻引擎

问题描述 投票:0回答:2

很抱歉打扰你们,但我在尝试进行一些测试以显示在自动化测试框架中时遇到了问题。我编写了两个基本测试(C++)只是为了看看插件中会发生什么,但当我打开会话前端时我看不到它们。有人可以帮忙吗?这可能是一个小错误......

提前非常感谢您!

#include "FMyTestUtils.h"
#include "Misc/AutomationTest.h"
#include "Tests/AutomationCommon.h"
#include "PlayableArea.h"
#include "UnrealEd.h"


IMPLEMENT_SIMPLE_AUTOMATION_TEST(FPACountTest, "Tests.FTrialTest", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter);

bool FPACountTest::RunTest(const FString& Parameters) 
{
    AutomationOpenMap("/Game/StarterContent/Maps/FTest_CountPAS.FTest_CountPAS");

    UWorld* World = FMyTestUtils::GetWorld();
    TestNotNull("Check if World is properly created", World);
    if (!World) return false;

    int32 PACount = 0;


    for (TActorIterator<APlayableArea> It(World); It; ++It) {
        PACount++;
    }

    TestTrue("Check if there are 4 PAS on the level", PACount == 3);

    ADD_LATENT_AUTOMATION_COMMAND(FExitGameCommand);

    return true;

}

我还尝试了虚幻文档中的那个:

#include "MyBot.h"



IMPLEMENT_SIMPLE_AUTOMATION_TEST(FPlaceholderTest, "TestGroup.TestSubgroup.Placeholder Test", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter);

bool FPlaceholderTest::RunTest(const FString& Parameters)
{
    // Make the test pass by returning true, or fail by returning false.
    return false;
}
c++ unit-testing unreal-engine4
2个回答
0
投票

我发现了这个问题!我正在视觉工作室中添加类,因此虚幻引擎无法找到它们。我只需将类从文件“Intermediate”中移出,并将其放入“源”中,然后再次生成 Visual Studio 项目文件,然后进行构建,它就会显示出来!


0
投票

有两件事需要检查,一是UE的测试插件应该启用,二是你的测试代码所在的模块应该包含在uproject文件中。

如果你的模块恰好在uproject中,也许你需要重新生成你的vs项目。

这里有一种重新生成vs工程的方法,不使用右键uproject的方法

https://forums.unrealengine.com/t/generate-cpp-project-couldnt-find-unrealbuildtool/231288/15?page=3

基本上你运行cmd,cd到你的UBT文件夹,运行

UnrealBuildTool.exe -projectfiles -project="path to your project\project name.uproject" -game -engine -rocket -progress

© www.soinside.com 2019 - 2024. All rights reserved.