RSS Feed

Unity Testing Folders

April 9, 2018

Release, Integration and Unit testing still have a way to go before they become firm friends with Unity3D.

 

This blog is about folders. It is not a good idea having test code or assets embedded in your production release. Apart from app bloat, there is a real possibility of unintended interactions. Resources in required unity packages can have assets of the same name. If production accidentally relies on test code, it is better to get a compile error than pollute a release with mock data.

 

In unity packages, I create I keep my tests in a directory called Examples. Examples provide one of the best ways to learn functionality. That they also test components is a happy coincidence. Even in application projects, the name is relevant, perhaps even more so. Developers are less likely to document internals for an application while it is still necessary to remember how parts of the system function and what limitations they have.

 

I create a directory Editor inside where I place almost everything. It is especially important to put a test-only Resources directory inside since otherwise all resources are loaded into the production system even when not referenced.

 

 

 

The only exceptions are scripts that are used in Play Mode or as support for test scenes. They won't work inside Editor folders. For these, I wrap the file contents in #if UNITY_EDITOR and #endif.

 

 

 

Share on Facebook
Share on Twitter
Please reload

Featured Posts

My limited tests show that Dictionary is faster than `SortedList`. The latter uses `Array.BinarySearch` to find entries. I have read other performance...

How are C# Dictionaries so Fast?

August 27, 2018

1/5
Please reload

Recent Posts

April 12, 2018

Please reload

Archive
Please reload

Search By Tags
Please reload

Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square