UE4 C++ (21) 自动化系统(AutoTest)

06/05/2021

自动化系统

别名自动测试(AutoTest),由UE4提供的。首先看一下UE4的例子。打开Window->DeveloperTool->SessionFrontend->Automation。
自动测试
可以选择System->Engine->FileSystem 和Attachment选项,然后开始测试

创建自动的自动化

UE4官网
UE4官网技术指南

此系统存在于"UObject"生态系统之外,所以它对 蓝图 或引擎的 反射系统 不可见

简单测试

创建一个空的[Name]Test.cpp文件

//UE4官方例子
#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FPlaceholderTest, "TestGroup.TestSubgroup.Placeholder Test", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
bool FPlaceholderTest::RunTest(const FString& Parameters)
{
   
    // 通过返回"真(true)"使测试通过,或者返回"假(false)"使测试失败。
    return true;
}

打开Session Frontend可以看到测试函数,因为EAutomationTestFlags::EditorContext
Session Frontend

//在Console command 也可以运行自动化,按照下面写法
automation runtest TestGroup.TestSubgroup.Placeholder Test

下面列子存在Runtime\Engine\Private\Tests\EngineAutomationTests.cpp,和官网提供的一致

IMPLEMENT_SIMPLE_AUTOMATION_TEST(FSetResTest, "System.Windows.Set Resolution", EAutomationTestFlags::ClientContext | EAutomationTestFlags::EngineFilter)
bool FSetResTest::RunTest(const FString& Parameters)
{
   

	//Gets the default map that the game uses.
	const UGameMapsSettings* GameMapsSettings = GetDefault<UGameMapsSettings>();
	const FString& MapName = GameMapsSettings->GetGameDefaultMap();

	//Opens the actual default map in game.
	GEngine->Exec(GetSimpleEngineAutomationTestGameWorld(GetTestFlags()), *FString::Printf(TEXT</
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值