Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed Apr 28, 2024
1 parent 578287d commit 5eec980
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Tests/Editor/LoadSceneAttributeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class LoadSceneAttributeTest

[Test]
[LoadScene(TestScene)]
public void Attach_AlreadyLoadedSceneNotInBuild()
public void Attach_LoadedSceneNotInBuild()
{
var cube = GameObject.Find(ObjectName);
Assert.That(cube, Is.Not.Null);
Expand Down
15 changes: 5 additions & 10 deletions Tests/Runtime/Utils/ScenePathFinderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using System;
using System.IO;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace TestHelper.Utils
{
Expand All @@ -16,30 +14,27 @@ public class ScenePathFinderTest
[TestCase("Packages/com.nowsprinting.test-helper/Tes?s/S?enes/NotInScenesInBuild.unity")]
[TestCase("Packages/com.nowsprinting.test-helper/*/*/NotInScenesInBuild.unity")]
[TestCase("Packages/com.nowsprinting.test-helper/**/NotInScenesInBuild.unity")]
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
public void GetExistScenePath_InEditor_GotExistScenePath(string path)
public void GetExistScenePath_ExistPath_GotExistScenePath(string path)
{
const string ExistScenePath = "Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity";

var actual = ScenePathFinder.GetExistScenePath(path);
Assert.That(actual, Is.EqualTo(ExistScenePath));
}

[TestCase("Tests/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity")]
[TestCase("Packages/**/NotInScenesInBuild.unity")]
[TestCase("**/NotInScenesInBuild.unity")]
[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild")]
[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/Not??ScenesInBuild.unity")]
[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/*InScenesInBuild.unity")]
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
public void GetExistScenePath_InEditor_ThrowsArgumentException(string path)
public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string path)
{
Assert.That(() => ScenePathFinder.GetExistScenePath(path), Throws.TypeOf<ArgumentException>());
}

[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotExistScene.unity")]
[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotExistScene.unity")] // Not exist path
[TestCase("Packages/com.nowsprinting.test-helper/*/NotInScenesInBuild.unity")] // Not match path pattern
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
public void GetExistScenePath_InEditor_ThrowsFileNotFoundException(string path)
public void GetExistScenePath_NotExistPath_ThrowsFileNotFoundException(string path)
{
Assert.That(() => ScenePathFinder.GetExistScenePath(path), Throws.TypeOf<FileNotFoundException>());
}
Expand Down

0 comments on commit 5eec980

Please sign in to comment.