-
Notifications
You must be signed in to change notification settings - Fork 77
The beginnings of a useful testing framework #1305
Conversation
test-project/Assets/EditmodeTests/Subscriptions/InjectionCriteriaTests.cs
Show resolved
Hide resolved
.Step(world => { world.Connection.CreateEntity(EntityId, BasicEntity()); }) | ||
.Step(world => | ||
{ | ||
var (_, readerBehaviour) = world.CreateGameObject<ExhaustiveSingularReaderBehaviour>(EntityId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a little unclear why this test works the way it does. Can we somehow make it clearer that this works because the BasicEntity
does not contain the component that the monobehaviour here has a reader for?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not change the tests themselves in this PR
test-project/Assets/EditmodeTests/Subscriptions/InjectionCriteriaTests.cs
Show resolved
Hide resolved
test-project/Assets/EditmodeTests/Subscriptions/RequireablesDisableTests.cs
Show resolved
Hide resolved
workers/unity/Packages/io.improbable.gdk.testutils/MockWorld.cs
Outdated
Show resolved
Hide resolved
a200f81
to
44b240e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, dont forget the changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like it :D
...ers/unity/Packages/io.improbable.gdk.core/Worker/ConnectionHandlers/MockConnectionHandler.cs
Show resolved
Hide resolved
a4707de
to
a608556
Compare
Description
This PR condenses some of the patterns we've used in testing into a
MockWorld
class which helps you write integration tests in a fluent and easy to understand way. The goal of this was to make it very easy to spin up the full stack with a mock connection and tick through frames. This is visible in the API which looks something like:The
MockWorld
classes has a minimal feature set, and can be extended in the future:<T1, T2>
&<T1, T2, T3>
version.This is all wrapped up in the
MockBase
abstract class which test fixtures can inherit from. This has a simpleSetUp
andTearDown
where the World is created and then disposed so each test can have a fresh world to start with.I've ported the existing tests in the Test Project to this new paradigm, there are tests in
Core
that would benefit from this API but we may want to move around the location of theMock*
objects in order to use them there.Commits are ordered!
Tests
Old tests ported & still passing.
Documentation