Skip to content

Commit

Permalink
Add FScopedGame
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Aug 5, 2024
1 parent 0fa8d0a commit e6a2334
Show file tree
Hide file tree
Showing 6 changed files with 579 additions and 2 deletions.
50 changes: 49 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,62 @@ ASSERT_THAT(Value, Is::Not::Null);

#TODO: Document how to write custom matchers#

== Running tests

UEST is seamlessly integrated into Unreal Engine testing infrastructure, so you can run them using standard Session Frontend or IDE integration plugins.

=== Testing game worlds

UEST provides a convenient way to test game worlds, both standalone and multiplayer.

.Basic usage
[source,cpp]
----
TEST(MyGame, SimpleMultiplayerTest)
{
auto Tester = FScopedGame().Create();
// You can create dedicated server
UGameInstance* Server = Tester.CreateGame(EScopedGameType::DedicatedServer, TEXT("/Engine/Maps/Entry"));
// You can connect a client to it
UGameInstance* Client = Tester.CreateClientFor(Server);
ASSERT_THAT(Client, Is::Not::Null);
// You can access game worlds
UWorld* ServerWorld = Server->GetWorld();
ASSERT_THAT(ServerWorld, Is::Not::Null);
UWorld* ClientWorld = Server->GetWorld();
ASSERT_THAT(ClientWorld, Is::Not::Null);
// You can access actors in worlds
APlayerController* ClientPC = ClientWorld->GetFirstPlayerController();
ASSERT_THAT(ClientPC, Is::Not::Null);
// You can lookup matching replicated actors in paired worlds
APlayerController* ServerPC = Tester.FindReplicatedObjectIn(ClientPC, Server->GetWorld());
ASSERT_THAT(ServerPC, Is::Not::Null);
// You can advance game time
Tester.Tick(1);
// You can shut down individual game instances
Tester.DestroyGame(Client);
// You can also create standalone game worlds
UGameInstance* Standalone = Tester.CreateGame(EScopedGameType::Client, TEXT("/Engine/Maps/Entry"));
// Tester automatically cleans everything up when goes out of scope
}
----

== Further development plans

* `BEFORE_EACH`/`AFTER_EACH` to `TEST_CLASS`
* More matchers
* Add `ASSERT_MULTIPLE` that allows performing multiple assertions without interrupting execution between them, also known as "soft assertions".
* Add API to disable tests (with `EAutomationTestFlags::Disabled` under the hood)
* Add API for asynchronous/latent tests
* API for UWorld testing

== Analysis of existing Unreal Engine solutions

Expand Down
Loading

0 comments on commit e6a2334

Please sign in to comment.