A game about forced loneliness, made by TACStudios
1using System;
2using NUnit.Framework;
3
4namespace UnityEngine.TestTools
5{
6 /// <summary>
7 /// The `UnitySetUp` and <see cref="UnityTearDownAttribute"/> attributes are identical to the standard `SetUp` and `TearDown` attributes, with the exception that they allow for <see cref="IEditModeTestYieldInstruction"/>. The `UnitySetUp` and `UnityTearDown` attributes expect a return type of [IEnumerator](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator?view=netframework-4.8).
8 /// </summary>
9 /// <example>
10 /// <code>
11 /// <![CDATA[
12 /// public class SetUpTearDownExample
13 /// {
14 /// [UnitySetUp]
15 /// public IEnumerator SetUp()
16 /// {
17 /// yield return new EnterPlayMode();
18 /// }
19 ///
20 /// [Test]
21 /// public void MyTest()
22 /// {
23 /// Debug.Log("This runs inside playmode");
24 /// }
25 ///
26 /// [UnityTearDown]
27 /// public IEnumerator TearDown()
28 /// {
29 /// yield return new ExitPlayMode();
30 /// }
31 /// }
32 /// ]]>
33 /// </code>
34 /// </example>
35 /// <example>
36 /// ## Base and Derived class example
37 /// <code>
38 /// <![CDATA[
39 /// public class BaseClass
40 /// {
41 /// [OneTimeSetUp]
42 /// public void OneTimeSetUp()
43 /// {
44 /// Debug.Log("OneTimeSetUp Base");
45 /// }
46 ///
47 /// [SetUp]
48 /// public void SetUp()
49 /// {
50 /// Debug.Log("SetUp Base");
51 /// }
52 ///
53 /// [UnitySetUp]
54 /// public IEnumerator UnitySetUp()
55 /// {
56 /// Debug.Log("UnitySetup Base");
57 /// yield return null;
58 /// }
59 ///
60 /// [TearDown]
61 /// public void TearDown()
62 /// {
63 /// Debug.Log("TearDown Base");
64 /// }
65 ///
66 /// [UnityTearDown]
67 /// public IEnumerator UnityTearDown()
68 /// {
69 /// Debug.Log("UnityTearDown Base");
70 /// yield return null;
71 /// }
72 /// }
73 ///
74 /// public class DerivedClass : BaseClass
75 /// {
76 /// [OneTimeSetUp]
77 /// public new void OneTimeSetUp()
78 /// {
79 /// Debug.Log("OneTimeSetUp");
80 /// }
81 ///
82 /// [SetUp]
83 /// public new void SetUp()
84 /// {
85 /// Debug.Log("SetUp");
86 /// }
87 ///
88 /// [UnitySetUp]
89 /// public new IEnumerator UnitySetUp()
90 /// {
91 /// Debug.Log("UnitySetup");
92 /// yield return null;
93 /// }
94 ///
95 /// [Test]
96 /// public void UnitTest()
97 /// {
98 /// Debug.Log("Test");
99 /// }
100 ///
101 /// [UnityTest]
102 /// public IEnumerator UnityTest()
103 /// {
104 /// Debug.Log("UnityTest before yield");
105 /// yield return null;
106 /// Debug.Log("UnityTest after yield");
107 /// }
108 ///
109 /// [TearDown]
110 /// public new void TearDown()
111 /// {
112 /// Debug.Log("TearDown");
113 /// }
114 ///
115 /// [UnityTearDown]
116 /// public new IEnumerator UnityTearDown()
117 /// {
118 /// Debug.Log("UnityTearDown");
119 /// yield return null;
120 /// }
121 ///
122 /// [OneTimeTearDown]
123 /// public void OneTimeTearDown()
124 /// {
125 /// Debug.Log("OneTimeTearDown");
126 /// }
127 /// }
128 /// ]]>
129 /// </code>
130 /// </example>
131 /// <example>
132 /// ## Domain reload example
133 /// <code>
134 /// <![CDATA[
135 /// public class BaseClass
136 /// {
137 /// [OneTimeSetUp]
138 /// public void OneTimeSetUp()
139 /// {
140 /// Debug.Log("OneTimeSetUp Base");
141 /// }
142 ///
143 /// [SetUp]
144 /// public void SetUp()
145 /// {
146 /// Debug.Log("SetUp Base");
147 /// }
148 ///
149 /// [UnitySetUp]
150 /// public IEnumerator UnitySetUp()
151 /// {
152 /// Debug.Log("UnitySetup Base");
153 /// yield return null;
154 /// }
155 ///
156 /// [TearDown]
157 /// public void TearDown()
158 /// {
159 /// Debug.Log("TearDown Base");
160 /// }
161 ///
162 /// [UnityTearDown]
163 /// public IEnumerator UnityTearDown()
164 /// {
165 /// Debug.Log("UnityTearDown Base");
166 /// yield return null;
167 /// }
168 /// }
169 ///
170 /// public class DerivedClass : BaseClass
171 /// {
172 /// [OneTimeSetUp]
173 /// public new void OneTimeSetUp()
174 /// {
175 /// Debug.Log("OneTimeSetUp");
176 /// }
177 ///
178 /// [SetUp]
179 /// public new void SetUp()
180 /// {
181 /// Debug.Log("SetUp");
182 /// }
183 ///
184 /// [UnitySetUp]
185 /// public new IEnumerator UnitySetUp()
186 /// {
187 /// Debug.Log("UnitySetup");
188 /// yield return null;
189 /// }
190 ///
191 /// [Test]
192 /// public void UnitTest()
193 /// {
194 /// Debug.Log("Test");
195 /// }
196 ///
197 /// [UnityTest]
198 /// public IEnumerator UnityTest()
199 /// {
200 /// Debug.Log("UnityTest before yield");
201 /// yield return new EnterPlayMode();
202 /// //Domain reload happening
203 /// yield return new ExitPlayMode();
204 /// Debug.Log("UnityTest after yield");
205 /// }
206 ///
207 /// [TearDown]
208 /// public new void TearDown()
209 /// {
210 /// Debug.Log("TearDown");
211 /// }
212 ///
213 /// [UnityTearDown]
214 /// public new IEnumerator UnityTearDown()
215 /// {
216 /// Debug.Log("UnityTearDown");
217 /// yield return null;
218 /// }
219 ///
220 /// [OneTimeTearDown]
221 /// public void OneTimeTearDown()
222 /// {
223 /// Debug.Log("OneTimeTearDown");
224 /// }
225 /// }
226 /// ]]>
227/// </code>
228/// </example>
229 [AttributeUsage(AttributeTargets.Method)]
230 public class UnitySetUpAttribute : NUnitAttribute
231 {
232 }
233}