UUnitTest

Base class for all unit tests

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

NetcodeUnitTest

Header

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

Include

#include "UnitTest.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)(Abstract, Config=UnitTestStats)
class UUnitTest : public UUnitTestBase

Remarks

Base class for all unit tests

Variables

Name Description

Protected variable

bool

 

bAborted

Whether or not the unit test has aborted execution

Protected variable

bool

 

bCompleted

Whether or not the unit test has completed

Protected variable

bool

 

bDeveloperMode

Whether or not developer-mode has been enabled for this unit test (prevents it from ending execution)

Protected variable

bool

 

bFirstTimeStats

Whether it's the first time this unit test has run, i.e. whether prior memory stats exist (

Not set until first tick)

Protected variable

bool

 

bObsolete

Whether or not this unit test is obsolete - i.e. based on code no longer present in the game/engine

Protected variable

bool

 

bUnreliable

Whether or not this unit test is unreliable, i.e. prone to giving incorrect/unexpected results, requiring multiple runs

Protected variable

bool

 

bWorkInProgress

Whether or not this unit test is a 'work in progress', and should not be included in automated tests

Protected variable

uint64

 

CurrentMemoryUsage

The current realtime memory usage of the unit test

Protected variable

TMap< FString, ...

 

ExpectedResult

The unit test result we expect for each games codebase, i.e. whether we expect that the problem is fixed yet or not

Public variable UProperty Config

float

 

LastExecutionTime

The amount of time it took to execute the unit test the last time it was run

Protected variable

double

 

LastNetTick

The time of the last NetTick event

Protected variable

double

 

LastTimeoutReset

The last time that the unit test timeout was reset

Protected variable

FString

 

LastTimeoutResetEvent

Every timeout reset specifies a string to identify/describe the event that triggered it, for tracking

Protected variable

TSharedPtr< SLo...

 

LogWindow

The log window associated with this unit test

Public variable UProperty Config

uint64

 

PeakMemoryUsage

Config variables Stores stats on the highest-ever reported memory usage, for this unit test - for estimating memory usage

Protected variable

double

 

StartTime

The time at which execution of the unit test started

Protected variable

TArray< TShared...

 

StatusLogSummary

Collects unit test status logs, that have been printed to the summary window

Protected variable

double

 

TimeoutExpire

The time at which the unit test timeout will expire

Public variable UProperty Config

float

 

TimeToPeakMem

The amount of time it takes to reach 'PeakMemoryUsage' (or within 90% of its value)

Protected variable

TUniquePtr< FOu...

 

UnitLog

The log file for outputting all log information for the current unit test

Protected variable

FString

 

UnitLogDir

The log directory for this unit test

Protected variable UProperty

TArray< UUnitTa...

 

UnitTasks

UnitTask's which must be run before different stages of the unit test can execute

Protected variable

EUnitTaskFlags

 

UnitTaskState

Marks the state of met unit task requirement flags and active unit task blocking flags

Protected variable

TArray< FString...

 

UnitTestBugTrackIDs

The bug tracking identifiers related to this unit test (e.g. TTP numbers)

Protected variable

TArray< FString...

 

UnitTestCLs

Source control changelists relevant to this unit test

Protected variable

FDateTime

 

UnitTestDate

The date this unit test was added to the project (for ordering in help command)

Protected variable

FString

 

UnitTestName

Variables which should be specified by every subclass The name/command for this unit test (N.B. Must be set in class constructor)

Protected variable

uint32

 

UnitTestTimeout

The amount of time (in seconds), before the unit test should timeout and be marked as broken

Protected variable

FString

 

UnitTestType

The type of unit test this is (e.g. bug/exploit) (N.B. Must be set in class constructor)

Protected variable UProperty

EUnitTestVerifi...

 

VerificationState

Whether or not the success or failure of the current unit test has been verified

Constructors

Name Description

Public function

UUnitTest

(
    const FObjectInitializer& ObjectIn...
)

UUnitTest

Functions

Name Description

Public function

void

 

AbortUnitTest()

Aborts execution of the unit test, part-way through

Public function

void

 

AddTask

(
    UUnitTask* InTask
)

Adds a UnitTask to the unit test, during its configuration stage - to be completed before executing the unit test

Public function Virtual

bool

 

CanResetUnitTest()

Whether or not this unit test supports resetting

Public function Virtual

void

 

CleanupUnitTest

(
    EUnitTestResetStage ResetStage
)

Cleans up all items needing destruction, and removes the unit test from tracking, before deleting the unit test itself

Public function

void

 

EndUnitTest()

Called upon completion of the unit test (may not happen during same tick), for tearing down created worlds/connections/etc.

Public function Virtual

bool

 

ExecuteUnitTest()

Executes the main unit test

Public function Virtual

void

 

GetCommandContextList

(
    TArray< TSharedPtr< FString >>& Ou...,
    FString& OutDefaultContext
)

Outputs the list of console command contexts, that this unit test supports (which can include custom contexts in subclasses)

Protected function Virtual

ELogType

 

GetExpectedLogTypes()

Returns the type of log entries that this unit expects to output, for setting up log window filters (only needs to return values which affect what tabs are shown)

Public function

EUnitTestVer...

 

GetExpectedResult()

Returns the expected result for the current game

Public function

TArray< FStr...

 

GetSupportedGames()

Returns the list of supported games, for this unit test

Public function Const

FDateTime

 

GetUnitTestDate()

Returns the date this unit test was first added to the code

Public function Const

FString

 

GetUnitTestName()

Returns the name/command, for the current unit test

Public function Const

uint32

 

GetUnitTestTimeout()

Returns the value of UnitTestTimeout

Public function Const

FString

 

GetUnitTestType()

Returns the type of unit test (e.g. bug/exploit)

Public function

bool

 

HasStarted()

Whether or not the unit test has started

Protected function Virtual

void

 

InitializeEnvironmentSettings()

Finishes initializing unit test settings, that rely upon the current unit test environment being loaded

Protected function

void

 

InitializeLogs()

Sets up the log directory and log output device instances.

Public function Const

bool

 

IsFirstTimeStats()

Returns whether or not this is the first time the unit test has been run/collecting-stats

Protected function

bool

 

IsTaskBlocking

(
    EUnitTaskFlags InFlag
)

Determines whether or not a UnitTask is blocking the specified event

Public function Virtual

void

 

LogComplete()

Triggered upon unit test completion, for outputting that the unit test has completed - plus other unit test state information

Public function Virtual

bool

 

NotifyConsoleCommandRequest

(
    FString CommandContext,
    FString Command
)

Notifies that there was a request to execute a console command for the unit test, which can occur in a specific context, e.g. for a unit test server, for a local minimal-client (within the unit test), or for a separate unit test client process

Public function

void

 

NotifyDeveloperModeRequest

(
    bool bInDeveloperMode
)

Notifies that there was a request to enable/disable developer mode

Protected function Virtual

void

 

NotifyUnitTaskFailure

(
    UUnitTask* InTask,
    FString Reason
)

Triggered when a UnitTask fails unrecoverably during execution

Protected function Virtual

void

 

ResetTimeout

(
    FString ResetReason,
    bool bResetConnTimeout,
    uint32 MinDuration
)

Resets the unit test timeout code - should be used liberally, within every unit test, when progress is made during execution

Public function

void

 

ResetUnitTest

(
    EUnitTestResetStage ResetStage
)

Resets the unit test to its initial state, allowing it to restart from scratch

Protected function Virtual

void

 

UnblockEvents

(
    EUnitTaskFlags ReadyEvents
)

When events that were pending but blocked by a UnitTask, are unblocked, this function triggers them.

Protected function Virtual

bool

 

ValidateUnitTestSettings

(
    bool bCDOCheck
)

Validate that the unit test settings/flags specified for this unit test, are compatible with one another, and that the engine settings/environment, support running the unit test.

Overridden from UUnitTestBase

Name Description

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

 

PostUnitTick

(
    float DeltaTime
)

For cleanup actions that should occur after the primary tick function is called

Public function Virtual

void

 

TickIsComplete

(
    float DeltaTime
)

Tick function for checking if the unit test is completed (happens after all above tick events)

Public function Virtual

void

 

UnitTick

(
    float DeltaTime
)

Main tick function for the unit test

Protected function Virtual

bool

 

UTStartUnitTest()

Overridden from FUnitLogInterface

Name Description

Public function Virtual

bool

 

IsConnectionLogSource

(
    UNetConnection* InConnection
)

Whether or not this log interface is the source of a UNetConnection - used for deciding where to direct, UNetConnection log hooks

Public function Virtual

bool

 

IsTimerLogSource

(
    UObject* InTimerDelegateObject
)

Whether or not this log interface is the source of an FTimerManager delegate object, used for hooking logs triggered during global timer manager delegates.

Public function Virtual

void

 

NotifyLocalLog

(
    ELogType InLogType,
    const TCHAR* Data,
    ELogVerbosity::Type Verbosity,
    const FName& Category
)

For implementation in subclasses, for helping to track local log entries related to a unit test.

Public function Virtual

void

 

NotifyStatusLog

(
    ELogType InLogType,
    const TCHAR* Data
)

As above, except for log entries directed towards the Unit Test Status window.

Constants

Name

Description

NullUnitEnv

The null unit test environment - for unit tests which support all games, due to requiring no game-specific features

UnitEnv

Runtime variables The unit test environment (not set until the current games unit test module is loaded - not set at all, if no such module)

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