Navigation
API > API/Plugins > API/Plugins/NetcodeUnitTest
Base class for all unit tests depending upon a MinimalClient connecting to a server. The MinimalClient handles creation/cleanup of an entire new UWorld, UNetDriver and UNetConnection, for fast unit testing.
NOTE: See NUTEnum.h, for important flags for configuring unit tests and the minimal client.
In subclasses, implement the unit test within the ExecuteClientUnitTest function (remembering to call parent)
| Name | UClientUnitTest |
| Type | class |
| Header File | /Engine/Plugins/NetcodeUnitTest/NetcodeUnitTest/Source/NetcodeUnitTest/Classes/ClientUnitTest.h |
| Include Path | #include "ClientUnitTest.h" |
Syntax
UCLASS (Abstract)
class UClientUnitTest : public UProcessUnitTest
Inheritance Hierarchy
- FUnitLogInterface → UUnitTestBase → UUnitTest → UProcessUnitTest → UClientUnitTest
- UObjectBase → UObjectBaseUtility → UObject → UUnitTestBase → UUnitTest → UProcessUnitTest → UClientUnitTest
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UClientUnitTest
(
const FObjectInitializer& ObjectInitializer |
UClientUnitTest | ClientUnitTest.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| OnlineBeaconClass_Private | TObjectPtr< UClass > | Cached reference to the OnlineBeaconClient static class | ClientUnitTest.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void ExecuteClientUnitTest() |
Interface and hooked events for client unit tests Override this, to implement the client unit test NOTE: Should be called last, in overridden functions IMPORTANT: EndUnitTest should be triggered, upon completion of the unit test (which may be delayed, for many unit tests) | ClientUnitTest.h | |
FString GetBeaconAddress() |
Accessor for BeaconAddress | ClientUnitTest.h | |
TWeakPtr< FUnitTestProcess > GetServerHandle() |
Accessor for ServerHandle | ClientUnitTest.h | |
EUnitTestFlags GetUnitTestFlags() |
Accessor for UnitTestFlags | ClientUnitTest.h | |
virtual bool HasAllCustomRequirements () |
Optionally, if the 'RequireCustom' flag is set, this returns whether custom conditions have been met. | ClientUnitTest.h | |
virtual void NotifyAllowNetActor
(
UClass* ActorClass, |
Notification triggered BEFORE a replicated actor has been created (allowing you to block creation, based on class) | ClientUnitTest.h | |
virtual void NotifyAlterMinClient
(
FMinClientParms& Parms |
Gives subclass UnitTest's an opportunity to alter the MinimalClient setup parameters | ClientUnitTest.h | |
virtual void NotifyControlMessage
(
FInBunch& Bunch, |
Override this, to receive notification of all other non-NMT_NUTControl control messages | ClientUnitTest.h | |
virtual void NotifyHandleClientPlayer
(
APlayerController* PC, |
Notification that the local net connections PlayerController has been replicated and is being setup | ClientUnitTest.h | |
virtual void NotifyMinClientConnected() |
Notification from the minimal client, that it has fully connected | ClientUnitTest.h | |
virtual void NotifyNetActor
(
UActorChannel* ActorChannel, |
Override this, to receive notification AFTER an actor channel actor has been created | ClientUnitTest.h | |
virtual void NotifyNetworkFailure
(
ENetworkFailure::Type FailureType, |
Triggered upon a network connection failure | ClientUnitTest.h | |
virtual void NotifyNUTControl
(
ENUTControlCommand CmdType, |
Override this, to receive notification of NMT_NUTControl messages, from the server | ClientUnitTest.h | |
| Overridable in subclasses - can be used to control/block any script events, other than receiving of RPC's (see NotifyReceiveRPC) | ClientUnitTest.h | ||
virtual void NotifyReceivedRawPacket
(
void* Data, |
If EUnitTestFlags::CaptureReceiveRaw is set, this is triggered for every packet received from the server NOTE: Data is a uint8 array, of size 'NETWORK_MAX_PACKET', and elements can safely be modified | ClientUnitTest.h | |
| Overridable in subclasses - can be used to control/block receiving of RPC's | ClientUnitTest.h | ||
virtual void NotifySendRPC
(
AActor* Actor, |
Overridable in subclasses - can be used to control/block sending of RPC's | ClientUnitTest.h | |
virtual void NotifySocketSendRawPacket
(
void* Data, |
Triggered for every packet sent to the server, when LowLevelSend is called. | ClientUnitTest.h | |
void OnRPCFailure() |
Callback for when an RPC send fails on the minimal client | ClientUnitTest.h | |
virtual void ReceivedControlBunch
(
FInBunch& Bunch |
Bunches received on the control channel. | ClientUnitTest.h | |
void SendGenericExploitFailLog () |
Sends a generic log message to the server, which (if successfully logged) indicates unit test failure. | ClientUnitTest.h | |
bool SendNUTControl
(
ENUTControlCommand CommandType, |
Utility functions for use by subclasses Sends an NMT_NUTControl control channel message, for the server NUTActor. | ClientUnitTest.h | |
bool SendRPCChecked
(
UObject* Target, |
See UMinimalClient | ClientUnitTest.h | |
bool SendRPCChecked
(
UObject* Target, |
See UMinimalClient | ClientUnitTest.h | |
bool SendUnitRPCChecked
(
FString RPCName |
As above, except executes a static UFunction in the unit test (must be prefixed with UnitTestServer_), on the unit test server, allowing unit tests to define and contain their own 'pseudo'-RPC's. | ClientUnitTest.h | |
bool SendUnitRPCChecked
(
FString RPCName |
As above, except allows 'UnitTestServer' RPC's to be located in an arbitrary class (e.g. if shared between unit tests), specified as the delegate parameter. | ClientUnitTest.h |
Overridden from UProcessUnitTest
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void NotifyProcessFinished
(
TWeakPtr< FUnitTestProcess > InProcess |
Notifies when a running process is detected as having finished/closed NOTE: This will not get called, when ShutdownUnitTestProcess is used, only when a program ends by itself | ClientUnitTest.h | |
virtual void NotifyProcessLog
(
TWeakPtr< FUnitTestProcess > InProcess, |
Interface for process unit tests For implementation in subclasses, for helping to verify success/fail upon completion of unit tests NOTE: Not called again once VerificationState is set WARNING: Be careful when iterating InLogLines in multiple different for loops, if the sequence of detected logs is important | ClientUnitTest.h | |
virtual void NotifyProcessSuspendState
(
TWeakPtr< FUnitTestProcess > InProcess, |
Notifies when the suspend state of a process changes | ClientUnitTest.h | |
virtual void NotifySuspendRequest() |
Notifies that there was a request to suspend/resume the unit test | ClientUnitTest.h |
Overridden from UUnitTest
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
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) | ClientUnitTest.h | |
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) | ClientUnitTest.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 | ClientUnitTest.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void CleanupMinimalClient() |
Cleans up the minimal client | ClientUnitTest.h | |
virtual bool ConnectMinimalClient
(
const TCHAR* InNetID |
Connects a minimal client, to the launched/launching server | ClientUnitTest.h | |
| Puts together the commandline parameters clients should use, based upon the unit test settings | ClientUnitTest.h | ||
virtual FString ConstructServerParameters() |
Puts together the commandline parameters the server should use, based upon the unit test settings | ClientUnitTest.h | |
EUnitTestFlags GetMetRequirements() |
Returns the requirements flags, that this unit test currently meets | ClientUnitTest.h | |
bool HasAllRequirements
(
bool bIgnoreCustom |
Whether or not all 'requirements' flag conditions have been met | ClientUnitTest.h | |
void SetFlags () |
Sets and validates at compile time, that the specified flags are valid. | ClientUnitTest.h | |
virtual TWeakPtr< FUnitTestProcess > StartUnitTestClient
(
FString ConnectIP, |
Starts a client process tied to the unit test, and connects to the specified server address | ClientUnitTest.h | |
virtual void StartUnitTestServer() |
Starts the server process for a particular unit test | ClientUnitTest.h | |
void TriggerAutoReconnect() |
Triggers an auto-reconnect (disconnect/reconnect) of the minimal client | ClientUnitTest.h | |
void ValidateUnitFlags
(
EUnitTestFlags RuntimeUnitFlags, |
Internal base implementation and utility functions for client unit tests Validates, both at compile time (template params) or at runtime (function params), that the specified flags are valid. | ClientUnitTest.h |
Overridden from UProcessUnitTest
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void PrintUnitTestProcessErrors
(
TSharedPtr< FUnitTestProcess > InHandle |
If any errors logs were detected upon ShutdownUnitTestProcess, this is called to print them out | ClientUnitTest.h |
Overridden from UUnitTest
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void CleanupUnitTest
(
EUnitTestResetStage ResetStage |
Cleans up all items needing destruction, and removes the unit test from tracking, before deleting the unit test itself | ClientUnitTest.h | |
virtual bool ExecuteUnitTest() |
Executes the main unit test | ClientUnitTest.h | |
virtual void LogComplete() |
Triggered upon unit test completion, for outputting that the unit test has completed - plus other unit test state information | ClientUnitTest.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 | ClientUnitTest.h | |
virtual void UnblockEvents
(
EUnitTaskFlags ReadyEvents |
When events that were pending but blocked by a UnitTask, are unblocked, this function triggers them. | ClientUnitTest.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. | ClientUnitTest.h |
Overridden from UUnitTestBase
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual bool IsTickable() |
Must override in subclasses, that need ticking. | ClientUnitTest.h | |
virtual void UnitTick
(
float DeltaTime |
Main tick function for the unit test | ClientUnitTest.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 | ClientUnitTest.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static const TCHAR * GetGenericExploitFailLog() |
Gets the generic log message that is used to indicate unit test failure | ClientUnitTest.h | |
static void GetNextServerPorts
(
int32& OutServerPort, |
Determine the next unique server ports to use - incremented to a new unique number, internally | ClientUnitTest.h |