UnityPlatformAttribute

class in UnityEngine.TestTools

切换到手册

描述

用于指定在其上运行的平台。

使用此类可以指定应该测试哪些平台。使用 RuntimePlatform 枚举可以指定平台,并指定列表的 includeexclude 属性以便设置某个测试是否应该应用于平台。 您还可以将一个或多个 RuntimePlatform 值作为参数传入 PlatformAttribute 构造函数,从而指定应该测试哪些平台。 如果没有使用 RuntimePlatformincludeexclude 指定任何内容,则测试所有平台。如果 include 属性不为空,则不排除任何测试。 另请参阅:RuntimePlatformincludeexclude

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

[TestFixture] public class TestClass { [Test] [UnityPlatform(RuntimePlatform.WindowsPlayer)] public void TestMethod() { Assert.AreEqual(Application.platform, RuntimePlatform.WindowsPlayer); } }

变量

exclude排除的平台。
include包含的平台。