Skip to content

Commit 19c42d2

Browse files
authored
Merge pull request #39 from nowsprinting/unity6
Upgrade to Unity 6
2 parents 3187077 + 0f68b17 commit 19c42d2

32 files changed

+959
-139
lines changed

.editorconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,6 @@ resharper_switch_statement_handles_some_known_enum_values_with_default_highlight
267267
# BannedApiAnalyzers
268268
dotnet_diagnostic.RS0030.severity = error
269269

270-
# Suppress C#8.0+ syntax sugar (for under Unity 2020.2 compatibility)
271-
# See: https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html
272-
resharper_convert_to_using_declaration_highlighting = none
273-
resharper_convert_to_null_coalescing_compound_assignment_highlighting = none
274-
resharper_merge_into_logical_pattern_highlighting = none
275-
resharper_use_negated_pattern_in_is_expression_highlighting = none
276-
277270
# Test codes for Unity Test Framework
278271
[**/Tests/**/*.cs]
279272

.github/workflows/test-integration.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ jobs:
4040
fail-fast: false
4141
matrix:
4242
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
43-
- 2019.4.40f1
44-
- 2020.3.49f1
45-
- 2021.3.45f1
46-
- 2022.3.62f1
4743
- 6000.0.43f1
4844
- 6000.0.44f1 # pin test-framework v1.5.1
4945
- 6000.0.59f2 # pin test-framework v1.6.0

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ jobs:
4141
fail-fast: false
4242
matrix:
4343
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
44-
- 2019.4.40f1
45-
- 2020.3.49f1
46-
- 2021.3.45f1
47-
- 2022.3.62f1
4844
- 6000.0.43f1
4945
- 6000.0.44f1 # pin test-framework v1.5.1
5046
- 6000.0.59f2 # pin test-framework v1.6.0

.idea/.idea.UnityTestExamples/.idea/copilot.data.migration.ask2agent.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"references": [
55
"UnityEngine.TestRunner",
66
"UnityEditor.TestRunner",
7-
"NUnit.Analyzers_Unity",
8-
"APIExamples.Tests",
9-
"UniTask",
10-
"TestHelper"
7+
"APIExamples.Tests",
8+
"UniTask",
9+
"TestHelper",
10+
"NUnit.Analyzers_Unity"
1111
],
1212
"includePlatforms": [
1313
"Editor"
@@ -22,6 +22,17 @@
2222
"defineConstraints": [
2323
"UNITY_INCLUDE_TESTS"
2424
],
25-
"versionDefines": [],
25+
"versionDefines": [
26+
{
27+
"name": "com.unity.test-framework",
28+
"expression": "1.5",
29+
"define": "ENABLE_UTF_1_5"
30+
},
31+
{
32+
"name": "com.unity.test-framework",
33+
"expression": "1.6",
34+
"define": "ENABLE_UTF_1_6"
35+
}
36+
],
2637
"noEngineReferences": false
2738
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) 2021-2025 Koji Hasegawa.
2+
// This software is released under the MIT License.
3+
4+
#if ENABLE_UTF_1_5
5+
using System.Collections;
6+
using System.Diagnostics.CodeAnalysis;
7+
using System.Threading.Tasks;
8+
using APIExamples.NUnit;
9+
using NUnit.Framework;
10+
using UnityEngine.TestTools;
11+
using Is = APIExamples.NUnit.Is;
12+
13+
namespace APIExamples.Editor.UnityTestFramework
14+
{
15+
/// <summary>
16+
/// <see cref="UnityOneTimeSetupAttributeExample"/>の使用例
17+
/// </summary>
18+
/// <remarks>
19+
/// Required: Unity Test Framework v1.5 or later
20+
/// </remarks>
21+
/// <seealso cref="AsyncSetupAttributeExample"/>
22+
/// <seealso cref="UnitySetUpAttributeExample"/>
23+
[TestFixture]
24+
[SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")]
25+
public class UnityOneTimeSetupAttributeExample
26+
{
27+
private int _oneTimeSetupCount;
28+
private int _setupCount;
29+
30+
/// <summary>
31+
/// テストクラス内の最初のテストの実行前に一度だけ実行されます
32+
/// </summary>
33+
[UnityOneTimeSetUp]
34+
public IEnumerator OneTimeSetUp()
35+
{
36+
yield return null;
37+
_oneTimeSetupCount++;
38+
}
39+
40+
/// <summary>
41+
/// 各テストメソッドの前に実行されます
42+
/// </summary>
43+
[SetUp]
44+
public void SetUp()
45+
{
46+
_setupCount++;
47+
}
48+
49+
[Test, Order(0)]
50+
public void TestMethod()
51+
{
52+
Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される");
53+
Assert.That(_setupCount, Is.EqualTo(1), "最初のテストなのでSetUpは1回実行されている");
54+
}
55+
56+
[Test, Order(1)]
57+
public async Task TestMethodAsync()
58+
{
59+
await Task.Yield();
60+
Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される");
61+
Assert.That(_setupCount, Is.EqualTo(2), "2番目のテストなのでSetUpは2回実行されている");
62+
}
63+
64+
[UnityTest, Order(2)]
65+
public IEnumerator UnityTestMethod()
66+
{
67+
yield return null;
68+
Assert.That(_oneTimeSetupCount, Is.EqualTo(1), "OneTimeSetUpはTestFixtureごとに一度だけ実行される");
69+
Assert.That(_setupCount, Is.EqualTo(3), "3番目のテストなのでSetUpは3回実行されている");
70+
}
71+
}
72+
}
73+
#endif

Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeSetupAttributeExample.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) 2021-2025 Koji Hasegawa.
2+
// This software is released under the MIT License.
3+
4+
#if ENABLE_UTF_1_5
5+
using System.Collections;
6+
using System.Diagnostics.CodeAnalysis;
7+
using System.Threading.Tasks;
8+
using APIExamples.NUnit;
9+
using NUnit.Framework;
10+
using UnityEngine;
11+
using UnityEngine.TestTools;
12+
using Is = APIExamples.NUnit.Is;
13+
14+
namespace APIExamples.Editor.UnityTestFramework
15+
{
16+
/// <summary>
17+
/// <see cref="UnityOneTimeTearDownAttributeExample"/>の使用例
18+
/// </summary>
19+
/// <remarks>
20+
/// Required: Unity Test Framework v1.5 or later
21+
/// </remarks>
22+
/// <seealso cref="AsyncTearDownAttributeExample"/>
23+
/// <seealso cref="UnityTearDownAttributeExample"/>
24+
[TestFixture]
25+
[SuppressMessage("ReSharper", "AccessToStaticMemberViaDerivedType")]
26+
public class UnityOneTimeTearDownAttributeExample
27+
{
28+
private int _oneTimeTeardownCount;
29+
private int _teardownCount;
30+
31+
/// <summary>
32+
/// クラス内の最後のテストの実行後に一度だけ実行されます
33+
/// </summary>
34+
[UnityOneTimeTearDown]
35+
public IEnumerator OneTimeTearDown()
36+
{
37+
yield return null;
38+
Debug.Log($"UnityOneTimeTearDown");
39+
_oneTimeTeardownCount++;
40+
41+
Assert.That(_oneTimeTeardownCount, Is.EqualTo(1), "OneTimeTearDownはTestFixtureごとに一度だけ実行される");
42+
Assert.That(_teardownCount, Is.EqualTo(3), "3つのテストがあるのでTearDownは3回実行されている");
43+
}
44+
45+
/// <summary>
46+
/// 各テストメソッドの後に実行されます
47+
/// </summary>
48+
[TearDown]
49+
public void TearDown()
50+
{
51+
Debug.Log($"TearDown");
52+
_teardownCount++;
53+
}
54+
55+
[Test]
56+
public void TestMethod()
57+
{
58+
Debug.Log($"TestMethod");
59+
}
60+
61+
[Test]
62+
public async Task TestMethodAsync()
63+
{
64+
await Task.Yield();
65+
Debug.Log($"TestMethodAsync");
66+
}
67+
68+
[UnityTest]
69+
public IEnumerator UnityTestMethod()
70+
{
71+
yield return null;
72+
Debug.Log($"UnityTestMethod");
73+
}
74+
}
75+
}
76+
#endif

Assets/APIExamples/Tests/Editor/UnityTestFramework/UnityOneTimeTearDownAttributeExample.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/APIExamples/Tests/Runtime/APIExamples.Tests.asmdef

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"UnityEngine.TestRunner",
66
"UnityEditor.TestRunner",
77
"APIExamples",
8-
"UniTask",
9-
"TestHelper"
8+
"UniTask",
9+
"TestHelper",
10+
"NUnit.Analyzers_Unity"
1011
],
1112
"includePlatforms": [],
1213
"excludePlatforms": [],
@@ -19,6 +20,17 @@
1920
"defineConstraints": [
2021
"UNITY_INCLUDE_TESTS"
2122
],
22-
"versionDefines": [],
23+
"versionDefines": [
24+
{
25+
"name": "com.unity.test-framework",
26+
"expression": "1.5",
27+
"define": "ENABLE_UTF_1_5"
28+
},
29+
{
30+
"name": "com.unity.test-framework",
31+
"expression": "1.6",
32+
"define": "ENABLE_UTF_1_6"
33+
}
34+
],
2335
"noEngineReferences": false
2436
}

0 commit comments

Comments
 (0)