- Home /
Unity 5.6 Unit Testing
I noticed that there have been some changes in the Unit Testing framework inside Unity. The only change that I saw documented (even though it was difficult to find) was that NUnit was updated to version 3.6. I updated and some of our Unit/Integration tests are now failing. We have some failing because calls are being made not on the main thread, and I've also noticed the new "PlayMode" in the test runner which I can find 0 information on it seems.
Can someone please either point me in a direction to see the update changes or explain what the PlayMode is and perhaps what core changes beyond the NUnit update have been made? I would greatly appreciate this, thank you.
Answer by Tomek-Paszek · Apr 06, 2017 at 12:36 PM
Hi!
The docs are taking a little linger to update then expected. Sorry about that. In the meantime here are the draft docs for the new test runner: https://docs.google.com/document/d/1SeNOAVYaq9HUjsKAC2ZvRwKLD2MCNyV4LwcsP3BXm0s/edit
In this version NUnit got updated from 2.6 to 3.5-based version. Update guide can be found here https://github.com/nunit/docs/wiki/Upgrading
Also feel free to write feedback for the docs. Let us know what is unclear, what could be improved, etc.
Hi $$anonymous$$ek! Is there still a way to run tests from custom assemblies (DLLs)? I have [Test] attributes in my classes, but since 5.6, they don't show up in the test runner anymore. I'm referencing Nunit Framework 3.5.0, as per your earlier comment.
The previous documentation stated:
The runner will scan the assemblies (including external assemblies included in the project that reference nunit.framework library)
But now that part seems to be gone in your Google Doc. Has that feature been removed?!
Hi ludiq. Unfortunatelly this wasn't implement in the new runner. It's a regerssion but we'll try to fix it.
Thanks for the clarification. That's disappointing, though... I'm developing a very complex asset store plugin that depends strongly on unit testing for quality assurance. Any rough ETA on the fix?
Hi, regarding the "Example in Edit mode": What should RunEditorUtilityInTheBackgroud look like? Is it possible to instantiate a class extending $$anonymous$$onoBehaviour inside a test in Edit$$anonymous$$ode? Will Awake() be called during the test?
I tried the following, where LateUpdate is called, Awake isn't:
GameObject gameObject = new GameObject();
$$anonymous$$yObject = gameObject.AddComponent (typeof($$anonymous$$yObject)) as $$anonymous$$yObject;
EditorApplication.update += Update;
// yield to skip a frame
yield return null;
When I try to run the example "$$anonymous$$onoBehaviourTest" from the draft docs in Edit$$anonymous$$ode I get the message "Edit$$anonymous$$ode test can only yield null" Is there any how-to for integration tests?
Thanks in advance.
It's because $$anonymous$$B require playmode to execute. You can use ExecuteInEdit$$anonymous$$odeAttrbute but it has it's limitations (you can find more about that in the docs).
$$anonymous$$ek, I'm really sorry to hijack these comments, but could we have someone from Unity comment in this thread?
It's about several regressions to the Test Runner in Unity 5.6. Performance issues and missing features from 5.5. I believe it's really important. Thanks!