Version: 2018.4

Is

class in UnityEngine.TestTools.Constraints

マニュアルに切り替える

説明

Provides Unity-specific constraint types for use with NUnit's Assert.That method.

NUnit allows test authors to write assertions using the Assert.That() method, where the first parameter is the object under test, and the second parameter describes the conditions that the object has to meet. These can often be expressed in a human-readable style, for example Assert.That(3, Is.Not.EqualTo(2)).

Unity extends NUnit's mechanisms with some custom Unity-specific constraint types, and declares this "Is" class as an overlay on top of NUnit's. To resolve ambiguity between NUnit's own Is class and Unity's, you must explicitly declare it in a using statement, like this:

using NUnit.Framework;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;

class MyTestClass { [Test] public void MyTest() { Assert.That(() => { var i = new int[500]; }, Is.AllocatingGCMemory()); } }

Static 関数

AllocatingGCMemoryDeclares a constraint that the provided delegate allocates GC memory.