Unity Editor crashing when running unit tests
I'm starting to write some really basic tests in NUnit to familiarise myself with unit testing in unity and my first test script causes the Editor to crash (terminate with no error message/warning) if I run all the tests. There are only 2 tests currently and I can't see any syntax errors or suchlike (they compile in monodevelop).
Curiously if i run the first test, it runs and passes as expected but running the second (which is practically identical) after causes the crash also. In case it was an issue with the latter test, I switched the order of the two in the code, and the new first test runs and passes and the second test (or running all tests) still crashes unity.
I've included the code of my test script below. I feel like either i'm missing something obvious or there is some aspect to using NUnit in unity which I don't know about and is causing this issue.
To clarify, when i say running the tests, i mean in the editor using the Editor Test Runner. I am using Unity 5.3.4f1 on OSX El Capitan if that makes any difference.
using UnityEngine;
using System.Collections;
using NUnit.Framework;
[TestFixture]
public class ReadJsonTest {
private JsonDataHandler handler;
[SetUp]
public void Init ()
{
handler = new JsonDataHandler();
}
[Test]
public void TestDialogueJsonDataLoaded() {
Assert.IsNotNull(handler.DialogueJsonData);
}
[Test]
public void TestItemsJsonDataLoaded() {
Assert.IsNotNull(handler.ItemsJsonData);
}
}
Answer by NoseKills · Aug 07, 2016 at 02:03 PM
If Unity crashes to desktop, it's a Unity bug. The best thing to do would be to make as small as possible a test project to reproduce the issue and report a bug with the test project attached.
I did so for a very similar issue. These issues might even have something in common.
Your answer
![](https://koobas.hobune.stream/wayback/20220612090321im_/https://answers.unity.com/themes/thub/images/avi.jpg)