Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity: Access classes in Assembly-CSharp from playmode tests

is it possible to reference Assembly-CSharp in play mode tests? I would like to test/use scripts in my tests but don't know how to reference Assembly-CSharp. thanks!

like image 814
xartal Avatar asked Nov 04 '25 20:11

xartal


1 Answers

The question was answered in the Unity forum by the User 'MafiaMoe':

The 'solution' is to right-click on the Test Runner tab and click 'Enable playmode tests for all assemblies'. Then (after a restart of Unity) playmode tests can be written directly in the game scripts. I think this video has a good example: youtube

However, after working play mode tests into our game development routine, I think I have a better idea how this is all supposed to work. > What we have been doing is keeping the 'Enable playmode tests for all assemblies' OFF and setting up test scenes that are already pre- configured to 'run-on-load'. With that, all the playmode test scripts need to do is load the scene and assert that certain log messages show up.

This seems to keep the process of creating and maintaining tests less convoluted, as almost all of the configuration happens within the editor. This also means no playmode tests are awkwardly included in the > game scripts, when this type of test seems best suited to validate interactions between multiple scripts within a game scene.

like image 101
xartal Avatar answered Nov 07 '25 16:11

xartal