Is it Good Practice to Include Unit Tests in Package Submissions?

I have a few small editor tools that I’d like to start writing unit tests for going forward. I have experience writing unit tests in other languages and have started to look into UTF.

My main question with this is if it’s good practice to include unit test files within the package itself, or keep those separate within the development unity project. Would including test files create any headaches for users or cause the package to be rejected during review?

Thanks!

It‘s up to you and whether you want to provide these code snippets to users. If you don‘t want that, the common approach is to make a separate package just for the tests. Many Unity packages follow this model.

PS: I am talking about Package Manager packages. In case you want to distribute via Unity Asset Store you should know that it doesn‘t (yet) use those packages but the old .unitypackage format.

Including unit tests in your package is a best practice in software development. It demonstrates a commitment to quality assurance and helps users understand how the asset is intended to be used. The test files can also serve as a testament to the quality of the code and, if designed well, can even be reused by others.

In case a user wants to remove the test folder, it’s a quick and straightforward process that can be done in just a few clicks. The benefits of including unit tests in your package far outweigh any potential drawbacks, making it an essential practice.

The Unity review process is unlikely to be impacted by the presence of test files, so don’t hesitate to include them in your package.

Good luck with your project!

In 10+ years on the Asset Store, I’m only aware of one user who used the unit tests available for a Pixel Crushers asset. (It’s possible there are more that I’m not aware of.) I assume most users expect the publisher to thoroughly test their assets before publishing.

As CodeSmile suggests, consider including them in a unitypackage. That way you won’t break the user’s project with compiler errors if they don’t have the Test Framework package installed in their project. If your tests use a significant amount of test data, you could alternatively make the unitypackage available for download from your publisher website.

Even if the Test Framework is uninstalled, the edit mode tests won’t cause any errors.

Awesome, thanks for the insights everyone!