UUnitTask

UnitTask's are used to implement supporting code for UnitTest's, for handling complex behind-the-scenes setup prior to test execution (e.g. primarily for implementing game-specific server/client environment setup), which is shared between many unit tests, and which is better to abstract-away from visibility in unit tests themselves, for code clarity.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

NetcodeUnitTest

Header

/Engine/Plugins/NetcodeUnitTest/NetcodeUnitTest/Source/NetcodeUnitTest/Classes/UnitTask.h

Include

#include "UnitTask.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)()
class UUnitTask :
    public UObject,
    public FUnitLogRedirect

Remarks

UnitTask's are used to implement supporting code for UnitTest's, for handling complex behind-the-scenes setup prior to test execution (e.g. primarily for implementing game-specific server/client environment setup), which is shared between many unit tests, and which is better to abstract-away from visibility in unit tests themselves, for code clarity.

For example, some games require authentication negotiation before the game client can connect to a server, and this is the type of task that UnitTask's are designed for.

Unit tasks that are added to a unit test, must complete execution before the unit test itself can execute.

Variables

Name Description

Protected variable

bool

 

bStarted

Whether or not the UnitTask has started

Protected variable

UUnitTest *

 

Owner

The UnitTest that owns this task

Protected variable

EUnitTaskFlags

 

UnitTaskFlags

Flags for configuring the UnitTask

Constructors

Name Description

Public function

UUnitTask

(
    const FObjectInitializer& ObjectIn...
)

UUnitTask

Functions

Name Description

Public function Virtual

void

 

Attach

(
    UUnitTest* InOwner
)

Attach the task to a unit test

Public function Virtual

void

 

Cleanup()

Cleanup the task state, after the task completes

Public function Const

EUnitTaskFla...

 

GetUnitTaskFlags()

Retrieves UnitTaskFlags

Public function

bool

 

HasStarted()

Whether or not the task has started

Public function Virtual

bool

 

IsTaskComplete()

Whether or not the task has completed

Public function Virtual Const

bool

 

IsTickable()

Must override in subclasses, that need ticking.

Public function Virtual

void

 

NetTick()

Tick function that runs at a tickrate of ~60 fps, for interacting with netcode (high UnitTick tickrate, can lead to net buffer overflows)

Public function Virtual

void

 

NotifyAlterMinClient

(
    FMinClientParms& Parms
)

Gives UnitTask's an opportunity to alter the MinimalClient setup parameters

Public function Virtual

void

 

ResetTimeout

(
    FString ResetReason,
    bool bResetConnTimeout,
    uint32 MinDuration
)

See UUnitTest::ResetTimeout

Public function Virtual

void

 

StartTask()

Start executing the task

Public function

void

 

TriggerFailure

(
    FString Reason
)

Triggers a failure for the UnitTask and owning UnitTest

Public function Virtual

void

 

UnitTick

(
    float DeltaTime
)

Events passed from the unit test Main tick function for the unit test

Public function Virtual

void

 

ValidateUnitTaskSettings()

After attaching to a unit test, validate the unit task settings are compatible

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss