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()); } }

정적 함수

AllocatingGCMemoryDeclares a constraint that the provided delegate allocates GC memory.