Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play mode tests #1168

Merged
merged 129 commits into from
Oct 9, 2023
Merged

Play mode tests #1168

merged 129 commits into from
Oct 9, 2023

Conversation

stilnat
Copy link
Contributor

@stilnat stilnat commented Apr 7, 2023

Summary

Taking back Ryan's work #1050 to have in game play mode tests. Citing Ryan :

Edit Mode

EditMode tests have been restructured to be more clear in what they are testing. Some PlayMode tests have been created. PlayMode tests require a build to be made, and most will automatically launch the build (where required) in order to establish client / server connections. I have restricted Playmode tests from running in github actions, intent is for this restriction to remain even after PR is complete and merged.

Play Mode

These are play mode tests that are intended to test game systems under runtime conditions. For example, a test could confirm the player ability to effectively embark onto the station at round start, and with late join etc.
Known Issue Replication [Not yet complete]

Known Issue Replication

These are play mode tests that are intended to provide actions to reliably reproduce a specific fault (as listed in github issues) under a variety of conditions, such as different server / host / client arrangements. This allows contributors attempting to resolve those faults to more clearly understand the problem, and thoroughly check whether all aspects of the issue have been resolved prior to pushing their solution.

Todo

  • Make the pickup test accessible to latejoin/host.
  • Fix the unworking tests when launched individually.
  • Fix the mouse input and action binding.
  • Document stuff correctly.
  • Move PlayerCanMoveInEachDirectionCorrectly, AssertCorrectPlayerPositionOnAxis, MoveInDirection in testHelper and PlayerTestRepository.
  • Complete PlayerCanMoveInEachDirectionCorrectly for host
  • Remove and simplify most of the test hierarchy, it's causing more trouble than it helps.

Changes to Files

  • add empty scene for tests.
  • Add a few TryGet methods instead of simple get.
  • Replaced old input.mouseposition with new input system.
  • remove itemCommandUtilities to put functionalities into item system (changes in itemcommand folder)
  • add a command spawn item in item system.
  • Add a string utility to convert a string to a given enum value.
  • Make all tests inherit from our own custom testing class SpessTest.

Technical Notes (optional)

Known issues

  • Sometimes (rare behavior) the tests start to fail for no clear reasons, most probably when some code is changed. Closing and opening again the editor fix it.

How to test it

  • Build the game (necessary for play tests testing clients)
  • Open the test runner (Window -> General -> Test runner)
  • Select play mode, you should see a list of different tests.
  • Just double click on one of them to run it.
  • Wait until it reach completion, there's nothing else to do.
  • Note that you need to do that for every test (need to be automatized)

image

Future work

  • Free Play
    These are play mode tests that do not contain Assertions, but rather a free play loop that can be exited by a certain key combination. The purpose of this is to easily load the game under specific configurations. This will allow specific scenarios to be created that can be playtested by a reviewer.
  • Add many more tests.
  • Add better support for mouse, it's currently only supporting left click, and left click is only doing primary interactions where the click happened.
  • Make all edit mode test inherit from SpessEditModeTest
  • Find a way to make all tests run in a row as expected (currently working one by one).
  • Add play tests to CI
  • Recording scenario ? That's highly hypothetical, but finding a way to record a series of input and play them again in a test, making assertions along the way, is probably the best way to test complex dynamics without too much effort.
    Helpful thread : https://forum.unity.com/threads/recording-and-replaying-input.739187/
  • Load empty scenes and build on it for specific test purpose.
  • Divide TestHelpers into multiple classes, dedicated to different help,such as TestMovementHelpers, TestInteractionHelpers...
  • Do something similar with PlayModeTestRepository.

Fixes (optional)

closes #1025
closes #984

Ryan089 and others added 30 commits January 25, 2023 21:14
Created separate test proxies and helpers to be used by all types.
@stilnat
Copy link
Contributor Author

stilnat commented May 15, 2023

Closed for now, to allow moving forward on other part of the code base.

@stilnat stilnat closed this May 15, 2023
@joaoburatto joaoburatto reopened this May 15, 2023
@cosmiccoincidence cosmiccoincidence added the Derelict Tasks that were closed/abandoned but contain some valuable info/code that may come of use. label May 16, 2023
@stilnat
Copy link
Contributor Author

stilnat commented Sep 12, 2023

Fixed, and updated to work with the current build.
All play tests should pass.

@stilnat stilnat reopened this Sep 12, 2023
@stilnat stilnat removed the Derelict Tasks that were closed/abandoned but contain some valuable info/code that may come of use. label Sep 12, 2023
@cosmiccoincidence
Copy link
Member

I would review this but I am unfamiliar with the testing "system" that is already implemented and ultimately don't know exactly how to run these tests in order to properly review the PR.

@stilnat
Copy link
Contributor Author

stilnat commented Sep 27, 2023

@cosmiccoincidence my request was more to let you know your previous request can be dismissed. However that made me think I should add a step by step guide to use it, so I'll do that (probably this weekend).

@cosmiccoincidence cosmiccoincidence added the Testing Tasks related to adding testing to already implemented features label Sep 27, 2023
Copy link
Member

@cosmiccoincidence cosmiccoincidence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected. Wish someone could have looked at the code a bit more but it's time this get merged already.

Don't forget to document this on gitbook.

@cosmiccoincidence cosmiccoincidence merged commit 35876e4 into RE-SS3D:develop Oct 9, 2023
2 checks passed
@stilnat stilnat deleted the PlayModeTests branch November 11, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority Life or death people, lets go! Testing Tasks related to adding testing to already implemented features
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add tests for late joining, early joining Add automatic client testing
5 participants