Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cba4293
Upgrade test-helper packages
nowsprinting Aug 11, 2025
573bc53
Fix BasicExample
nowsprinting Aug 10, 2025
edea50d
Fix package examples
nowsprinting Aug 11, 2025
d6145b7
Fix APIExample
nowsprinting Aug 11, 2025
2aa997b
Fix TimeoutAttribute examples
nowsprinting Aug 30, 2025
3e4a74a
Add missing script validators
nowsprinting Sep 20, 2025
a9b1dea
Upgrade Unity versions used to run tests on CI (Unity 6.2.6f1, test-f…
nowsprinting Oct 4, 2025
56063f4
Change com.unity.testframework.graphics package to optional
nowsprinting Oct 4, 2025
e4771de
Upgrade test-helper package to v1.2.3
nowsprinting Oct 4, 2025
1e3171d
Add check test-framework version tests
nowsprinting Oct 4, 2025
d03b490
Fix check test-framework version tests
nowsprinting Oct 17, 2025
6d7d18e
Fix to reduce delays
nowsprinting Nov 4, 2025
83e0e28
Fix DelayedConstraint example
nowsprinting Nov 4, 2025
382f3ae
Fix time thresholds
nowsprinting Nov 6, 2025
120a860
Update limitations version
nowsprinting Nov 6, 2025
c2f91bb
Fix setup and teardown examples
nowsprinting Nov 6, 2025
78f0afe
Upgrade Unity version to 6000.0.43f1
nowsprinting Oct 4, 2025
b384a7a
Fix Unity versions used to run tests on CI
nowsprinting Oct 4, 2025
e04015d
Remove suppress C#8.0+ syntax sugar (for under Unity 2020.2 compatibi…
nowsprinting Oct 4, 2025
0da6192
Add version defines
nowsprinting Nov 4, 2025
7cc100b
Add UnityOneTimeSetUp and TearDown attribute examples (UTF 1.5+)
nowsprinting Nov 6, 2025
d6ade97
Add IPrebuildSetupWithTestData examples (UTF 1.6+)
nowsprinting Nov 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,6 @@ resharper_switch_statement_handles_some_known_enum_values_with_default_highlight
# BannedApiAnalyzers
dotnet_diagnostic.RS0030.severity = error

# Suppress C#8.0+ syntax sugar (for under Unity 2020.2 compatibility)
# See: https://www.jetbrains.com/help/resharper/Reference__Code_Inspections_CSHARP.html
resharper_convert_to_using_declaration_highlighting = none
resharper_convert_to_null_coalescing_compound_assignment_highlighting = none
resharper_merge_into_logical_pattern_highlighting = none
resharper_use_negated_pattern_in_is_expression_highlighting = none

# Test codes for Unity Test Framework
[Tests/**/*.cs]

Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.inputs.runner }}
cancel-in-progress: true

permissions: {}
permissions: { }

defaults:
run:
Expand All @@ -40,16 +40,14 @@ jobs:
fail-fast: false
matrix:
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
- 2019.4.40f1
- 2020.3.48f1
- 2021.3.45f1
- 2022.3.59f1
- 2023.2.20f1
- 6000.0.41f1
- 6000.0.43f1
- 6000.0.44f1 # pin test-framework v1.5.1
- 6000.0.59f2 # pin test-framework v1.6.0
- 6000.2.7f2
testMode:
- All # run tests in editor
include:
- unityVersion: 6000.0.41f1
- unityVersion: 6000.2.7f2
testMode: Standalone # run tests on player

steps:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}
permissions: { }

defaults:
run:
Expand All @@ -41,18 +41,18 @@ jobs:
fail-fast: false
matrix:
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
- 2019.4.40f1
- 2020.3.48f1
- 2021.3.45f1
- 2022.3.59f1
- 2023.2.20f1
- 6000.0.41f1
- 6000.0.43f1
- 6000.0.44f1 # pin test-framework v1.5.1
- 6000.0.59f2 # pin test-framework v1.6.0
- 6000.2.5f1 # pin test-framework v1.5.1
- 6000.2.6f1 # pin test-framework v1.6.0
- 6000.2.7f2
testMode:
- All # run tests in editor
include:
- unityVersion: 6000.0.41f1
- unityVersion: 6000.2.7f2
octocov: true
- unityVersion: 6000.0.41f1
- unityVersion: 6000.2.7f2
testMode: Standalone # run tests on player

steps:
Expand Down
6 changes: 6 additions & 0 deletions Assets/APIExamples/Scripts/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("APIExample.Editor.Tests")]
3 changes: 3 additions & 0 deletions Assets/APIExamples/Scripts/Editor/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/APIExamples/Scripts/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("APIExample.Editor")]
[assembly: InternalsVisibleTo("APIExample.Editor.Tests")]
[assembly: InternalsVisibleTo("APIExample.Tests")]
3 changes: 3 additions & 0 deletions Assets/APIExamples/Scripts/Runtime/AssemblyInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions Assets/APIExamples/Scripts/Runtime/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
namespace APIExamples
{
/// <summary>
/// 元素的な属性.
/// 元素的な属性
/// </summary>
/// <remarks>
/// このenumは <c>BasicExample.Entities.Enums.Element</c> とは異なります(仕様を簡略化しました)
/// </remarks>
public enum Element
{
None,
Expand All @@ -22,7 +19,7 @@ public enum Element
public static class ElementExtensions
{
/// <summary>
/// 属性名を返す.
/// 属性名を返す
/// </summary>
/// <param name="self"></param>
/// <returns></returns>
Expand All @@ -44,7 +41,7 @@ public static string GetName(this Element self)
}

/// <summary>
/// 属性攻撃を受けたときの被ダメージ倍率を返す.
/// 属性攻撃を受けたときの被ダメージ倍率を返す
/// </summary>
/// <param name="self"></param>
/// <param name="attack">攻撃側の属性</param>
Expand Down
17 changes: 15 additions & 2 deletions Assets/APIExamples/Tests/Editor/APIExamples.Editor.Tests.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"UniTask"
"APIExamples.Tests",
"UniTask",
"TestHelper"
],
"includePlatforms": [
"Editor"
Expand All @@ -19,6 +21,17 @@
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"versionDefines": [
{
"name": "com.unity.test-framework",
"expression": "1.5",
"define": "ENABLE_UTF_1_5"
},
{
"name": "com.unity.test-framework",
"expression": "1.6",
"define": "ENABLE_UTF_1_6"
}
],
"noEngineReferences": false
}
5 changes: 2 additions & 3 deletions Assets/APIExamples/Tests/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) 2021-2022 Koji Hasegawa.
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using NUnit.Framework;

[assembly: Category("APIExamples")]

Original file line number Diff line number Diff line change
@@ -1,46 +1,57 @@
// Copyright (c) 2021-2023 Koji Hasegawa.
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System.Collections;
using System.Threading.Tasks;
using NUnit.Framework;
using UnityEngine;

#pragma warning disable CS1998
using UnityEngine.TestTools;

namespace APIExamples.Editor.NUnit
{
/// <summary>
/// 非同期の<see cref="SetUpAttribute"/>の例(Edit Modeテスト)
/// <see cref="OneTimeSetUpAttribute"/>はasyncサポートされていない(UTF v1.3時点)
/// 非同期の<see cref="SetUpAttribute"/>の使用例(Edit Modeテスト)
/// <see cref="OneTimeSetUpAttribute"/>はasyncサポートされていない(UTF v1.6.0時点)
/// <p/>
/// Async SetUp attribute example (in Edit Mode tests)
/// Async OneTimeSetUp attribute is not yet supported in UTF v1.3
/// Async OneTimeSetUp attribute is not yet supported in UTF v1.6.0
/// </summary>
/// <remarks>
/// Required: Unity Test Framework v1.3 or later
/// </remarks>
/// <seealso cref="APIExamples.Editor.UnityTestFramework.UnitySetUpAttributeExample"/>
[TestFixture]
public class AsyncSetupAttributeExample
{
private int _setupCount;

/// <summary>
/// 各テストメソッドの前に実行されます
/// </summary>
[SetUp]
public async Task SetUp()
public async Task SetUpAsync()
{
await Task.Delay(200);
Debug.Log($"SetUp, {Time.time}");
await Task.Yield();
_setupCount++;
}

[Test]
[Test, Order(0)]
public void TestMethod()
{
Debug.Log($"TestMethod, {Time.time}");
Assert.That(_setupCount, Is.EqualTo(1), "最初のテストなのでSetUpは1回実行されている");
}

[Test, Order(1)]
public async Task TestMethodAsync()
{
await Task.Yield();
Assert.That(_setupCount, Is.EqualTo(2), "2番目のテストなのでSetUpは2回実行されている");
}

[Test]
public void TestMethod2()
[UnityTest, Order(2)]
public IEnumerator UnityTestMethod()
{
Debug.Log($"TestMethod2, {Time.time}");
yield return null;
Assert.That(_setupCount, Is.EqualTo(3), "3番目のテストなのでSetUpは3回実行されている");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
// Copyright (c) 2021-2023 Koji Hasegawa.
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System.Collections;
using System.Threading.Tasks;
using NUnit.Framework;
using UnityEngine;

#pragma warning disable CS1998
using UnityEngine.TestTools;

namespace APIExamples.Editor.NUnit
{
/// <summary>
/// 非同期の<see cref="TearDownAttribute"/>の例(Edit Modeテスト)
/// <see cref="OneTimeTearDownAttribute"/>はasyncサポートされていない(UTF v1.3時点)
/// 非同期の<see cref="TearDownAttribute"/>の使用例(Edit Modeテスト)
/// <see cref="OneTimeTearDownAttribute"/>はasyncサポートされていない(UTF v1.6.0時点)
/// <p/>
/// Async TearDown attribute example (in Edit Mode tests)
/// Async OneTimeTearDown attribute is not yet supported in UTF v1.3
/// Async OneTimeTearDown attribute is not yet supported in UTF v1.6.0
/// </summary>
/// <remarks>
/// Required: Unity Test Framework v1.3 or later
/// </remarks>
/// <seealso cref="APIExamples.Editor.UnityTestFramework.UnityTearDownAttributeExample"/>
[TestFixture]
public class AsyncTearDownAttributeExample
{
/// <summary>
/// 各テストメソッドの後に実行されます
/// </summary>
[TearDown]
public async Task TearDown()
public async Task TearDownAsync()
{
await Task.Delay(200);
Debug.Log($"TearDown, {Time.time}");
await Task.Yield();
Debug.Log($"TearDownAsync");
}

[Test]
public void TestMethod()
{
Debug.Log($"TestMethod, {Time.time}");
Debug.Log($"TestMethod");
}

[Test]
public void TestMethod2()
public async Task TestMethodAsync()
{
await Task.Yield();
Debug.Log($"TestMethodAsync");
}

[UnityTest]
public IEnumerator UnityTestMethod()
{
Debug.Log($"TestMethod2, {Time.time}");
yield return null;
Debug.Log($"UnityTestMethod");
}
}
}
13 changes: 5 additions & 8 deletions Assets/APIExamples/Tests/Editor/NUnit/AsyncTestExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2023 Koji Hasegawa.
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System;
Expand All @@ -8,9 +8,6 @@
using NUnit.Framework;
using UnityEngine;

#pragma warning disable CS1998
// ReSharper disable AccessToStaticMemberViaDerivedType

namespace APIExamples.Editor.NUnit
{
/// <summary>
Expand All @@ -35,13 +32,13 @@ public async Task 非同期テストの例_Taskをawaitできる()

private static async Task Foo(int id)
{
await Task.Delay(200);
await Task.Yield();
Debug.Log($"Foo({id})");
}

private static async Task<int> Bar(int id)
{
await Task.Delay(200);
await Task.Yield();
Debug.Log($"Bar({id})");
return id + 1;
}
Expand All @@ -58,13 +55,13 @@ public async Task 非同期テストの例_UniTaskをawaitできる()

private static async UniTask UniTaskFoo(int id)
{
await UniTask.Delay(200);
await Task.Yield();
Debug.Log($"UniTaskFoo({id})");
}

private static async UniTask<int> UniTaskBar(int id)
{
await UniTask.Delay(200);
await Task.Yield();
Debug.Log($"UniTaskBar({id})");
return id + 1;
}
Expand Down
Loading