Skip to content

Commit

Permalink
Add reproducing tests environment
Browse files Browse the repository at this point in the history
Reproducing steps:
1. Stay keep is not playing
2. Open the scene "Error"
3. Open an inspector for "AutopilotSettingsForFacingImmediatelyError"
4. Click Run

Expected Behaviour:
Stop playing and report the error to Slack

Actual Behaviour:
Still playing and did not report to Slack
  • Loading branch information
Kuniwak committed Nov 9, 2023
1 parent cd0170e commit f5eaf92
Show file tree
Hide file tree
Showing 12 changed files with 684 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Tests/Runtime/TestDoubles/StubClickAgent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2023 DeNA Co., Ltd.
// This software is released under the MIT License.

using System.Threading;
using Cysharp.Threading.Tasks;
using DeNA.Anjin.Agents;
using UnityEngine;
using UnityEngine.EventSystems;

namespace DeNA.Anjin.TestDoubles
{
public class StubClickAgent : AbstractAgent
{
[SerializeField] public string targetName;

public override UniTask Run(CancellationToken token)
{
foreach (var obj in FindObjectsByType<GameObject>(FindObjectsSortMode.None))
{
if (obj.name != targetName)
{
continue;
}

var target = obj;
if (!target.TryGetComponent<IPointerClickHandler>(out var handler))
{
Debug.LogWarning(
$"{target.name} did not have any components that derived {nameof(IPointerClickHandler)}"
);
continue;
}

handler.OnPointerClick(new PointerEventData(EventSystem.current));
}
return UniTask.CompletedTask;
}
}
}
3 changes: 3 additions & 0 deletions Tests/Runtime/TestDoubles/StubClickAgent.cs.meta

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

22 changes: 22 additions & 0 deletions Tests/Runtime/TestDoubles/StubThrowingErrorOnClick.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2023 DeNA Co., Ltd.
// This software is released under the MIT License.

using System;
using System.Threading;
using UnityEngine;
using UnityEngine.EventSystems;

namespace DeNA.Anjin.TestDoubles
{
/// <summary>
/// A test stub throw errors when clicked
/// </summary>
[AddComponentMenu("")]
public class StubThrowingErrorOnClick : MonoBehaviour, IPointerClickHandler
{
public void OnPointerClick(PointerEventData eventData)
{
throw new Exception($"TEST on thread #{Thread.CurrentThread.ManagedThreadId}");
}
}
}
3 changes: 3 additions & 0 deletions Tests/Runtime/TestDoubles/StubThrowingErrorOnClick.cs.meta

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

33 changes: 33 additions & 0 deletions Tests/TestAssets/AutopilotSettingsForFacingImmediatelyError.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c7a1731caa574ed4b9334b7d52febe27, type: 3}
m_Name: AutopilotSettingsForFacingImmediatelyError
m_EditorClassIdentifier:
description:
sceneAgentMaps:
- scenePath: Packages/com.dena.anjin/Tests/TestScenes/Error.unity
agent: {fileID: 11400000, guid: 9a5c6d18335194c1b9f8e162695d73fd, type: 2}
fallbackAgent: {fileID: 0}
observerAgent: {fileID: 0}
lifespanSec: 0
randomSeed:
timeScale: 1
junitReportPath:
slackToken:
slackChannels:
mentionSubTeamIDs:
addHereInSlackMessage: 0
handleException: 1
handleError: 1
handleAssert: 1
handleWarning: 0
ignoreMessages: []

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

16 changes: 16 additions & 0 deletions Tests/TestAssets/StubClickAgentForTests.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fcc96872a9564f89be6b16a814ad0034, type: 3}
m_Name: StubClickAgentForTests
m_EditorClassIdentifier:
description:
targetName: ThrowErrorFromMainThreadOnClick
8 changes: 8 additions & 0 deletions Tests/TestAssets/StubClickAgentForTests.asset.meta

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

15 changes: 15 additions & 0 deletions Tests/TestAssets/StubImmediatelyErrorAgentForTests.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc82cbd7e5b6404da291e090ed1f4eba, type: 3}
m_Name: StubImmediatelyErrorAgentForTests
m_EditorClassIdentifier:
description:
8 changes: 8 additions & 0 deletions Tests/TestAssets/StubImmediatelyErrorAgentForTests.asset.meta

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

Loading

0 comments on commit f5eaf92

Please sign in to comment.