0

I set up my test environment for PlayMode testing.

Tests marked with [Test] work just fine, e.g. if my code looks like:

using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace Tests
{
    public class WinTestSuite
    {
        [Test]
        public void WinTestSuiteDummy()
        {
            Assert.IsTrue(false);
        }
    }
}

... and then run all tests, the Test Runner output looks like:

good run

(as expected)

Tests marked [UnityTest] seem to automatically pass without running, though. If I edit my test suite to look like this:

using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace Tests
{
    public class WinTestSuite
    {
        [UnityTest]
        public IEnumerable WinTestSuiteDummy()
        {
            Debug.Log("Hello world");
            yield return null;
            Assert.IsTrue(false);
        }
    }
}

The output I'm seeing is:

bad run

Looks like it isn't even running (can't see the Hello world anywhere), but I'm getting passing marks. What am I doing wrong?

Blue
  • 820
  • 4
  • 17
Dori
  • 1,035
  • 1
  • 12
  • 22
  • What is your target platform? `Unity Test Framework version 1.0.18 includes the following known limitations: (among others) The UnityTest attribute does not support WebGL and WSA platforms.` could this be the issue? – derHugo Nov 03 '20 at 15:09
  • Ah. So no windows standalone support? That could be the issue... how would I test my project for windows platform? I'm using version ```1.1.18``` – Dori Nov 03 '20 at 15:39
  • What I posted actually **is** from the page of version [1.1.18](https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/index.html) and not sure ... I guess you could try and stick to `Test` and wait for async stuff in a different way. Note btw that `WSA` stands for `Windows Store Application` (UWP), not for Standalone – derHugo Nov 03 '20 at 15:47
  • OK, so that's not the problem (probably). Thanks though – Dori Nov 03 '20 at 16:09

1 Answers1

0

Solution: replace the IEnumerable with IEnumerator as the return type in the method marked [UnityTest] (many thanks to Nadav Etinzon for pointing it out). Everything now runs as expected. It's a mystery to me why the runner didn't complain about the type mismatch, and instead chose to pretend everything is running smoothly... I'm curious if someone knows the answer to that :)

Dori
  • 1,035
  • 1
  • 12
  • 22