Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
41b6226
Fix Constraint examples
nowsprinting Nov 8, 2025
664d91e
Add RequirePlatformSupportAttributeExample
nowsprinting Nov 24, 2025
ca8e000
Add ITestRunCallbackExample
nowsprinting Nov 24, 2025
f3653d3
Add Vector2/3/4ComparerWithEqualsOperator example
nowsprinting Nov 24, 2025
6cd7398
Add TestCaseData with TestName
nowsprinting Nov 29, 2025
106d6ae
Fix TestDoubleExample
nowsprinting Nov 30, 2025
d4103c1
Fix .editorconfig
nowsprinting Dec 6, 2025
45bf372
Fix MonoBehaviourTestExample
nowsprinting Dec 6, 2025
c3c2cf1
Upgrade UniTask to v2.5.10
nowsprinting Dec 8, 2025
c7fe53b
Upgrade create-script-folders-with-tests package to v1.3.0
nowsprinting Dec 8, 2025
b168e88
Upgrade test-helper.random package to v1.1.0
nowsprinting Dec 8, 2025
656f5a1
Upgrade test-helper package to v1.3.2
nowsprinting Dec 8, 2025
68dfbb1
Upgrade test-helper.ui package to v1.1.3
nowsprinting Dec 8, 2025
a02b96e
Fix warnings
nowsprinting Dec 8, 2025
c4533aa
Upgrade Unity versions used to run tests on CI (Unity 6.3)
nowsprinting Dec 16, 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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ resharper_merge_into_logical_pattern_highlighting = none
resharper_use_negated_pattern_in_is_expression_highlighting = none

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

# Access to a static member of a type via a derived type (e.g., NUnit.Framework.Is)
resharper_access_to_static_member_via_derived_type_highlighting = none
Expand Down
14 changes: 8 additions & 6 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 @@ -41,15 +41,17 @@ jobs:
matrix:
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
- 2019.4.40f1
- 2020.3.48f1
- 2020.3.49f1
- 2021.3.45f1
- 2022.3.59f1
- 2023.2.20f1
- 6000.0.41f1
- 2022.3.62f1
- 6000.0.43f1
- 6000.0.44f1 # pin test-framework v1.5.1
- 6000.0.59f2 # pin test-framework v1.6.0
- 6000.3.1f1
testMode:
- All # run tests in editor
include:
- unityVersion: 6000.0.41f1
- unityVersion: 6000.3.1f1
testMode: Standalone # run tests on player

steps:
Expand Down
18 changes: 11 additions & 7 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 @@ -42,17 +42,21 @@ jobs:
matrix:
unityVersion: # Available versions see: https://game.ci/docs/docker/versions
- 2019.4.40f1
- 2020.3.48f1
- 2020.3.49f1
- 2021.3.45f1
- 2022.3.59f1
- 2023.2.20f1
- 6000.0.41f1
- 2022.3.62f1
- 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.3.1f1
testMode:
- All # run tests in editor
include:
- unityVersion: 6000.0.41f1
- unityVersion: 6000.3.1f1
octocov: true
- unityVersion: 6000.0.41f1
- unityVersion: 6000.3.1f1
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.

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

using UnityEditor;
Expand All @@ -8,21 +8,21 @@
namespace APIExamples.Editor.UnityTestFramework
{
/// <summary>
/// Test RunnerコールバックAPI使用例
/// <see href="https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/reference-ierror-callbacks.html"/>
/// Test RunnerコールバックAPI使用例.
/// <see href="https://docs.unity3d.com/Packages/com.unity.test-framework@1.6/api/UnityEditor.TestTools.TestRunner.Api.IErrorCallbacks.html"/>
/// </summary>
/// <remarks>
/// `OnError()`を除いて、<see cref="UnityEditor.TestTools.TestRunner.Api.ICallbacks"/>に定義されている
/// `OnError()`は、<see cref="UnityEditor.TestTools.TestRunner.Api.IErrorCallbacks"/>にのみ定義されている
/// </remarks>
/// <inheritdoc/>
public class CallbacksExample : IErrorCallbacks
/// <seealso cref="ITestRunCallbackExample"/>
public class ICallbacksExample : IErrorCallbacks
{
[InitializeOnLoadMethod]
private static void SetupCallbacks()
{
var api = ScriptableObject.CreateInstance<TestRunnerApi>();
api.RegisterCallbacks(new CallbacksExample());
api.RegisterCallbacks(new ICallbacksExample());
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using APIExamples.Editor.UnityTestFramework;
using NUnit.Framework.Interfaces;
using UnityEngine.TestRunner;

[assembly: TestRunCallback(typeof(ITestRunCallbackExample))]

namespace APIExamples.Editor.UnityTestFramework
{
/// <summary>
/// Test RunnerコールバックAPI使用例.
/// <see href="https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.TestRunner.ITestRunCallback.html"/>
/// </summary>
/// <seealso cref="ICallbacksExample"/>
public class ITestRunCallbackExample : ITestRunCallback
{
/// <inheritdoc/>
public void RunStarted(ITest testsToRun)
{
// テスト実行が開始されるときに呼ばれます
}

/// <inheritdoc/>
public void RunFinished(ITestResult testResults)
{
// テスト実行が終了したときに呼ばれます
}

/// <inheritdoc/>
public void TestStarted(ITest test)
{
// 個々の(Test Runnerウィンドウにおける)ツリーノードが開始されるときに呼ばれます
}

/// <inheritdoc/>
public void TestFinished(ITestResult result)
{
// 個々の(Test Runnerウィンドウにおける)ツリーノードが終了したときに呼ばれます
}
}
}

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
44 changes: 44 additions & 0 deletions Assets/APIExamples/Scripts/Runtime/MyMonoBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) 2021-2025 Koji Hasegawa.
// This software is released under the MIT License.

using System.Diagnostics.CodeAnalysis;
using UnityEngine;

namespace APIExamples
{
/// <summary>
/// <see cref="APIExamples.UnityTestFramework.MonoBehaviourTestExample"/> のテスト対象.
/// 生成されて5フレームで破棄されます
/// </summary>
[SuppressMessage("ReSharper", "InvalidXmlDocComment")]
public class MyMonoBehaviour : MonoBehaviour
{
protected bool _wasAwake;
protected bool _wasStart;
protected bool _wasDestroy;
private int _frameCount;

private void Awake()
{
_wasAwake = true;
}

private void Start()
{
_wasStart = true;
}

private void Update()
{
if (++_frameCount > 4)
{
Destroy(this.gameObject);
}
}

private void OnDestroy()
{
_wasDestroy = true;
}
}
}
3 changes: 3 additions & 0 deletions Assets/APIExamples/Scripts/Runtime/MyMonoBehaviour.cs.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"UniTask"
"NUnit.Analyzers_Unity",
"APIExamples.Tests",
"UniTask",
"TestHelper"
],
"includePlatforms": [
"Editor"
Expand Down
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回実行されている");
}
}
}
Loading