docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Namespace UnityEngine.TestTools.Constraints

    Classes

    AllocatingGCMemoryConstraint

    An NUnit test constraint class to test whether a given block of code makes any GC allocations.

    Use this class with NUnit's Assert.That() method to make assertions about the GC behaviour of your code. The constraint executes the delegate you provide, and checks if it has caused any GC memory to be allocated. If any GC memory was allocated, the constraint passes; otherwise, the constraint fails.

    Usually you negate this constraint to make sure that your delegate does not allocate any GC memory. This is easy to do using the Is class:

    ConstraintExtensions

    An NUnit test constraint class to test whether a given block of code makes any GC allocations.

    Is

    Extension of the Is class in NUnit.Framework, see Is.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)