Skip to content

Commit

Permalink
Add comments about async test problems
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed Oct 15, 2023
1 parent 732d9cf commit af67d55
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Assets/APIExamples/Tests/Editor/NUnit/AsyncTestExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private static async Task ThrowNewExceptionInMethod()
public async Task 非同期メソッドの例外捕捉を制約モデルで行なう例()
{
Assert.That(async () => await ThrowNewExceptionInMethod(), Throws.TypeOf<ArgumentException>());
// Note: Edit Modeテストでは動作するが、Play Modeテストではテストが終了しない https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28107
}
// Note: Edit Modeテストでは動作するが、Play Modeテストではテストが終了しない https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28107

[Test]
public async Task 非同期メソッドの例外捕捉をThrowsAsyncで行なう例()
Expand Down
3 changes: 2 additions & 1 deletion Assets/APIExamples/Tests/Runtime/NUnit/ConstraintExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ public void DelayedConstraint_Test属性のテストでは無効()
}

[Test]
[Explicit("Asyncテストでも期待通り動作しないので除外")]
[Explicit("Asyncテストでも期待通り動作しないので除外(Unity Test Framework v1.3.2時点)")]
// https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-30529
public async Task DelayedConstraint_AsyncTestでも無効()
{
var start = Time.time; // The time at the beginning of this frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public IEnumerator MaxTime属性はUnityTest属性のテストに使用できな
[Explicit("MaxTime属性はasyncテストに使用できない(Unity Test Framework v1.3.2時点)")]
// https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28107
[UnityPlatform(exclude = new[] { RuntimePlatform.WebGLPlayer })]
// WebGLでTask.Delayが終了しない https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28109
// WebGLではTask.Delayが終了しない(v1.3.2時点) https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28109
[Test]
[MaxTime(2000)]
public async Task MaxTime属性は非同期テストに使用できない_実行すると無限ループ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IEnumerator タイムアウトのデフォルトは3分()

[UnityTest]
[Timeout(2000)]
public IEnumerator タイムアウトを1秒に設定()
public IEnumerator タイムアウトを2秒に設定()
{
var waitSeconds = 1f;
if (Fail)
Expand Down Expand Up @@ -91,5 +91,21 @@ public IEnumerator タイムアウトはWaitForSeconds以外では有効でな
yield return null; // Timeout時間を超えてもテストは中断されない。指定時間を超過していれば失敗と判定はされる
}
}

[Test]
[Timeout(2000)]
// Note: Unity Test Framework v1.3.0時点では、Timeout属性はasyncテストでは機能しない
// https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-28108
// この問題は、Unity Test Framework v1.3.4で修正された
public async Task 非同期テストでタイムアウトを2秒に設定()
{
var waitSeconds = 1f;
if (Fail)
{
waitSeconds = 10f;
}

await Task.Delay(TimeSpan.FromSeconds(waitSeconds));
}
}
}

0 comments on commit af67d55

Please sign in to comment.