Navigation
API > API/Plugins > API/Plugins/NetcodeUnitTest
Base class for all unit tests
| Name | UUnitTest |
| Type | class |
| Header File | /Engine/Plugins/NetcodeUnitTest/NetcodeUnitTest/Source/NetcodeUnitTest/Classes/UnitTest.h |
| Include Path | #include "UnitTest.h" |
Syntax
UCLASS (Abstract, Config=UnitTestStats)
class UUnitTest : public UUnitTestBase
Inheritance Hierarchy
- FUnitLogInterface → UUnitTestBase → UUnitTest
- UObjectBase → UObjectBaseUtility → UObject → UUnitTestBase → UUnitTest
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UUnitTest
(
const FObjectInitializer& ObjectInitializer |
UUnitTest | UnitTest.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| NullUnitEnv | FUnitTestEnvironment * | The null unit test environment - for unit tests which support all games, due to requiring no game-specific features | UnitTest.h |
| UnitEnv | FUnitTestEnvironment * | 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) | UnitTest.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| LastExecutionTime | float | The amount of time it took to execute the unit test the last time it was run | UnitTest.h |
|
| PeakMemoryUsage | uint64 | Config variables Stores stats on the highest-ever reported memory usage, for this unit test - for estimating memory usage | UnitTest.h |
|
| TimeToPeakMem | float | The amount of time it takes to reach 'PeakMemoryUsage' (or within 90% of its value) | UnitTest.h |
|
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bVerificationLogged | bool | Whether or not the verification state was already logged (prevent spamming in developer mode) | UnitTest.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AbortUnitTest() |
Aborts execution of the unit test, part-way through | UnitTest.h | |
void AddTask
(
UUnitTask* InTask |
Adds a UnitTask to the unit test, during its configuration stage - to be completed before executing the unit test | UnitTest.h | |
virtual bool CanResetUnitTest() |
Whether or not this unit test supports resetting | UnitTest.h | |
virtual void CleanupUnitTest
(
EUnitTestResetStage ResetStage |
Cleans up all items needing destruction, and removes the unit test from tracking, before deleting the unit test itself | UnitTest.h | |
void EndUnitTest () |
Called upon completion of the unit test (may not happen during same tick), for tearing down created worlds/connections/etc. | UnitTest.h | |
virtual bool ExecuteUnitTest() |
Executes the main unit test | UnitTest.h | |
virtual void GetCommandContextList
(
TArray< TSharedPtr< FString > >& OutList, |
Outputs the list of console command contexts, that this unit test supports (which can include custom contexts in subclasses) | UnitTest.h | |
EUnitTestVerification GetExpectedResult() |
Returns the expected result for the current game | UnitTest.h | |
| Returns the list of supported games, for this unit test | UnitTest.h | ||
FDateTime GetUnitTestDate() |
Returns the date this unit test was first added to the code | UnitTest.h | |
FString GetUnitTestName() |
Returns the name/command, for the current unit test | UnitTest.h | |
uint32 GetUnitTestTimeout() |
Returns the value of UnitTestTimeout | UnitTest.h | |
FString GetUnitTestType() |
Returns the type of unit test (e.g. bug/exploit) | UnitTest.h | |
bool HasStarted() |
Whether or not the unit test has started | UnitTest.h | |
bool IsFirstTimeStats() |
Returns whether or not this is the first time the unit test has been run/collecting-stats | UnitTest.h | |
virtual void LogComplete() |
Triggered upon unit test completion, for outputting that the unit test has completed - plus other unit test state information | UnitTest.h | |
| 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 | UnitTest.h | ||
void NotifyDeveloperModeRequest
(
bool bInDeveloperMode |
Notifies that there was a request to enable/disable developer mode | UnitTest.h | |
void ResetUnitTest
(
EUnitTestResetStage ResetStage |
Resets the unit test to its initial state, allowing it to restart from scratch NOTE: Must be implemented for every unit test that intends to support it, through CleanupUnitTest | UnitTest.h |
Overridden from UUnitTestBase
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool IsTickable() |
Must override in subclasses, that need ticking. | UnitTest.h | |
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) | UnitTest.h | |
virtual void PostUnitTick
(
float DeltaTime |
For cleanup actions that should occur after the primary tick function is called | UnitTest.h | |
virtual void TickIsComplete
(
float DeltaTime |
Tick function for checking if the unit test is completed (happens after all above tick events) | UnitTest.h | |
virtual void UnitTick
(
float DeltaTime |
Main tick function for the unit test | UnitTest.h |
Overridden from FUnitLogInterface
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
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 | UnitTest.h | |
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. | UnitTest.h | |
virtual void NotifyLocalLog
(
ELogType InLogType, |
For implementation in subclasses, for helping to track local log entries related to a unit test. | UnitTest.h | |
virtual void NotifyStatusLog
(
ELogType InLogType, |
As above, except for log entries directed towards the Unit Test Status window. | UnitTest.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
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) | UnitTest.h | |
virtual void InitializeEnvironmentSettings() |
Finishes initializing unit test settings, that rely upon the current unit test environment being loaded | UnitTest.h | |
void InitializeLogs() |
Sets up the log directory and log output device instances. | UnitTest.h | |
bool IsTaskBlocking
(
EUnitTaskFlags InFlag |
Determines whether or not a UnitTask is blocking the specified event | UnitTest.h | |
| Triggered when a UnitTask fails unrecoverably during execution | UnitTest.h | ||
virtual void ResetTimeout
(
FString ResetReason, |
Resets the unit test timeout code - should be used liberally, within every unit test, when progress is made during execution | UnitTest.h | |
virtual void UnblockEvents
(
EUnitTaskFlags ReadyEvents |
When events that were pending but blocked by a UnitTask, are unblocked, this function triggers them. | UnitTest.h | |
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. | UnitTest.h |
Overridden from UUnitTestBase
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool UTStartUnitTest() |
UnitTest.h |