Skip to content

Commit

Permalink
Merge pull request #142 from nowsprinting/chore/fix_flaky_test
Browse files Browse the repository at this point in the history
Fix flaky test in the Samples
  • Loading branch information
nowsprinting authored Oct 6, 2024
2 parents cc478f6 + 568244e commit 6bb024e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Samples~/uGUI Demo/Tests/Runtime/MonkeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using NUnit.Framework;
using TestHelper.Attributes;

Expand All @@ -22,6 +23,9 @@ public async Task Run()
Screenshots = new ScreenshotOptions() // Take screenshots
};
await Monkey.Run(config);

// teardown
await UniTask.Delay(1000);
}
}
}
6 changes: 3 additions & 3 deletions Samples~/uGUI Demo/Tests/Runtime/ScenarioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ public async Task OpenSubScreens(string target)
var startButton = await _finder.FindByNameAsync("StartButton", interactable: true);
var startComponent = startButton.GetInteractableComponents().First();
var startOperator = startComponent.SelectOperators<IClickOperator>(_config.Operators).First();
startOperator.OperateAsync(startComponent);
await startOperator.OperateAsync(startComponent);

await _finder.FindByNameAsync("Home");

// When click target button, then open target screen.
var targetButton = await _finder.FindByNameAsync($"{target}Button", interactable: true);
var targetComponent = targetButton.GetInteractableComponents().First();
var targetOperator = targetComponent.SelectOperators<IClickOperator>(_config.Operators).First();
targetOperator.OperateAsync(targetComponent);
await targetOperator.OperateAsync(targetComponent);

await _finder.FindByNameAsync(target);

// When click Back button, then return Home screen.
var backButton = await _finder.FindByPathAsync($"**/{target}/BackButton", interactable: true);
var backComponent = backButton.GetInteractableComponents().First();
var backOperator = backComponent.SelectOperators<IClickOperator>(_config.Operators).First();
backOperator.OperateAsync(backComponent);
await backOperator.OperateAsync(backComponent);

await _finder.FindByNameAsync("Home");
}
Expand Down

0 comments on commit 6bb024e

Please sign in to comment.