UUnitTestManager

Manages centralized execution and tracking of unit tests, as well as handling console commands, and some misc tasks like local log hooking

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

NetcodeUnitTest

Header

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

Include

#include "UnitTestManager.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)(Config=UnitTest)
class UUnitTestManager :
    public UObject,
    public FTickableGameObject,
    public FOutputDevice

Remarks

Manages centralized execution and tracking of unit tests, as well as handling console commands, and some misc tasks like local log hooking

Variables

Name Description

Public variable

TSharedPtr< SWi...

 

AbortAllDialog

The 'abort all' dialog

Public variable UProperty

TArray< UUnitTe...

 

ActiveUnitTests

Holds a list of currently active unit tests

Public variable UProperty Config

uint8

 

AutoCloseMemoryPercent

As above, but when reaching this limit, recently started unit test(s) will be terminated/re-queued, to get back within limits

Public variable

bool

 

bAbortedFirstRunUnitTest

If a unit test was aborted on its first run, strictly cap all first-run unit tests to one at a time

Public variable

bool

 

bAllowRequeuingUnitTests

Whether or not to allow re-queuing of unit tests

Public variable UProperty Config

bool

 

bCapUnitTestCount

Whether or not to cap the maximum number of unit tests that can be active at any given time

Public variable UProperty Config

bool

 

bCapUnitTestMemory

Whether or not to cap active unit tests, based on memory usage

Public variable UProperty

TArray< UUnitTe...

 

FinishedUnitTests

Unit tests which are finished, and are kept around until printing the final summary

Public variable UProperty Config

uint8

 

MaxAutoCloseCount

Limits the number of auto-aborts a particular unit test will allow, before it is no longer accepted for re-queueing

Public variable UProperty Config

uint8

 

MaxMemoryPercent

When total physical memory usage, as a percentage, reaches this limit, no new unit tests can be started

Public variable UProperty Config

uint8

 

MaxUnitTestCount

Specifies the maximum number of unit tests that can be run at any given time

Public variable UProperty

TArray< UClass ...

 

PendingUnitTests

Holds a list of unit tests pending execution

Public variable

TUniquePtr< FOu...

 

StatusLog

The log file for outputting overall unit test status

Public variable

TSharedPtr< SLo...

 

StatusWindow

The log window which displays the overall status of unit testing

Public variable UProperty Config

uint32

 

UnitTestSessionCount

The number of recorded session where UE4 has run unit tests (max one per each run of the UE4 process)

Constructors

Name Description

Public function

UUnitTestManager

(
    const FObjectInitializer& ObjectIn...
)

UUnitTestManager

Destructors

Name Description

Public function Virtual

~UUnitTestManager()

Destructor for handling removal of log registration

Functions

Name Description

Public function

void

 

DumpStatus

(
    bool bForce
)

Dumps status information for running/pending unit tests, to the status window and log

Public function

bool

 

Exec

(
    UWorld* InWorld,
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Handles exec commands starting with 'UnitTest'

Public function Static

UUnitTestMan...

 

Get()

Static getter for the unit test manager

Public function

const FStrin...

 

GetBaseUnitLogDir()

Returns the base log directory used by unit tests

Public function Static

FSlateColor

 

GetDefaultStatusColor()

Public function

void

 

Initialize()

Initialize the unit test manager

Public function

void

 

InitializeLogs()

Initialize unit test log output

Public function

bool

 

IsRunningUnitTests()

Returns whether or not there are unit tests running (or about to be run)

Public function

void

 

NotifyCloseAllDialogResult

(
    const TSharedRef< SWindow >& Dialo...,
    EAppReturnType::Type Result,
    bool bNoResult
)

When the main status window is closed, a dialog pops up asking if you want to abort all running unit tests; this returns the result

Public function

void

 

NotifyCloseDialogResult

(
    const TSharedRef< SWindow >& Dialo...,
    EAppReturnType::Type Result,
    bool bNoResult
)

When a log window is closed, a dialog pops up asking if the unit test should be aborted - this returns the result NOTE: This dialog is non-modal, i.e. doesn't block the game thread - so the unit test is not guaranteed to still exist

Public function

void

 

NotifyLogWindowClosed

(
    const TSharedRef< SWindow >& Close...
)

Notifies when a log window has closed

Public function

void

 

NotifyUnitTestCleanup

(
    UUnitTest* InUnitTest
)

Notification that is triggered when a unit test is cleaning up

Public function

void

 

NotifyUnitTestComplete

(
    UUnitTest* InUnitTest,
    bool bAborted
)

Notification that is triggered when a unit test completes

Public function

void

 

OpenStatusWindow()

Opens the status log window

Public function

void

 

OpenUnitTestLogWindow

(
    UUnitTest* InUnitTest
)

Opens the log window, for a unit test

Public function

void

 

PollUnitTestQueue()

Checks to see if we're ready to execute any unit tests in the queue, and if so, begins execution

Public function

void

 

PrintFinalSummary()

Prints the final unit test summary, when all active/pending unit tests have completed

Public function

void

 

PrintUnitTestResult

(
    UUnitTest* InUnitTest,
    bool bFinalSummary,
    bool bUnfinished
)

Prints the results information for a single unit test

Public function

bool

 

QueueUnitTest

(
    UClass* UnitTestClass,
    bool bRequeued
)

Queues a unit test for execution

Public function Virtual

void

 

Serialize

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

We're hiding UObject::Serialize() by declaring this. That's OK, but Clang will warn about it.

Public function

void

 

SetStatusColor

(
    FSlateColor InStatusColor
)

Public function

void

 

SetStatusLog

(
    bool bInStatusLog
)

Getters/Setters

Public function

bool

 

WithinUnitTestLimits

(
    UClass* PendingUnitTest
)

Tests whether currently active unit tests, and optionally/additionally, a unit test about to be executed, fall within limits/restrictions on unit test counts and memory usage

Overridden from FTickableGameObject

Name Description

Public function Virtual Const

bool

 

IsTickableWhenPaused()

Used to determine if an object should be ticked when the game is paused.

Overridden from FTickableObjectBase

Name Description

Public function Virtual Const

TStatId

 

GetStatId()

Return the stat id to use for this tickable

Public function Virtual Const

bool

 

IsTickable()

Must override in subclasses, that need ticking.

Public function Virtual

void

 

Tick

(
    float DeltaTime
)

FTickableGameObject methods

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