-
Notifications
You must be signed in to change notification settings - Fork 7
How to write first test
How To Set Up Puppetry Environment
-
Be sure that Puppetry.Puppeteer nuget package is installed
-
Set all needed configuration by
Set(Settings setting, object value)
in TestRun initialization (OneTimeSetUp). No need to set them every test as it is static properties that will be used in every test. -
Call
Editor.StartPlayMode()
in Test Initialization (SetUp) to start PlayMode in the Editor. -
Describe all game objects that will interact with, in Arrange/Given part of a test or in ScreenObject class (adaptation of PageObject pattern). Example of initializing:
var button = new GameObject("RootElement", "GameObjectName");
-
Make actions with initialized game objects in Act/When part of a test. Example:
button.Click();
Note: Be sure that the game object is exist in the hierarchy, before you interact with it to avoid NoSuchGameObjectException (use Should(Be.Present) before the action). -
Check result of a test in Assert/Then with Should/ShouldNot methods of needed game object. Example:
menuLabel.Should(Be.Present); menuLabel.Should(Be.ActiveInHierarchy);
-
In Test clean up method (TearDown) if test result is failed, call
Game.MakeScreenshot()
to create and save screenshot with the game, to check why test is failed. -
Call
Editor.StopPlayMode();
in Test clean up method (TearDown) to stop play mode. -
Call
Driver.KillAllSessions();
in Test run clean up (OneTimeTearDown) to kill all sessions that were created.
- Add GameObject with component "InGameApiClientLoader" to start connection with Puppetry.PuppetryDriver
- Launch the game to initialize Puppet of Puppetry.
- Write scenario of test that want to execute (to stop and to start game again, you should launch it on the device/platform again). It is more difficult to write isolated tests