Purpose: Ensure Unity executable and test scripts are correctly located. Needed so Node script can launch Unity in batch mode and access test assemblies.
Find Unity executable path
# Unity executable path (replace with your version)~/Unity/Editors/6000.0.65f1/Editor/Unity
Purpose: Configure VSCode to debug Node scripts and attach automatically to Unity. This allows hitting breakpoints in C# test files while Unity runs in batch mode.
Purpose: Makes Unity pause until the debugger is attached, which ensures breakpoints in test scripts actually trigger.
Optional: Track time for running tests
Add the following near the top of the test file
DebugHelpers
namespace DebugHelpers{ using System; using System.Diagnostics; using System.Threading; using NUnit.Framework; [SetUpFixture] public class DebugWaitAndTimer { public static Stopwatch StopwatchInstance { get; private set; } [OneTimeSetUp] public void OnSuiteStart() { StopwatchInstance = Stopwatch.StartNew(); TestContext.Progress.WriteLine($"=== Test Suite Started: {DateTime.Now:yyyy-MM-dd HH:mm:ss} ==="); if (Environment.GetEnvironmentVariable("WAIT_FOR_DEBUGGER") == "1") { TestContext.Progress.WriteLine("READY_TO_ATTACH: Waiting for VSCode debugger..."); while (!Debugger.IsAttached) { Thread.Sleep(100); } } } [OneTimeTearDown] public void OnSuiteEnd() { StopwatchInstance.Stop(); TestContext.Progress.WriteLine($"=== Test Suite Finished (SetUpFixture) === Total Duration: {StopwatchInstance.Elapsed}"); } } // Dummy test fixture to inject total duration into NUnit XML [TestFixture] public class ZZZ_TestSuiteFinalizer { [Test] public void LogTotalDuration() { var total = DebugWaitAndTimer.StopwatchInstance?.Elapsed ?? TimeSpan.Zero; TestContext.WriteLine($"=== Test Suite Finished === Total Duration: {total}"); Assert.Pass(); } }}
4. Node Script: run-unity-tests.js
Purpose: Automates running Unity headless, passing environment variables, and invoking the Python parser to format test results.