Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed Apr 28, 2024
1 parent 5eec980 commit 385d58e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Tests/Editor/TemporaryBuildScenesUsingInTestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ namespace TestHelper.Editor
[TestFixture]
public class TemporaryBuildScenesUsingInTestTest
{
private const string TestScene = "Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity";

[Test]
public void GetScenesUsingInTest_AttachedToMethod_ReturnScenesSpecifiedByAttribute()
{
var actual = TemporaryBuildScenesUsingInTest.GetScenesUsingInTest();
Assert.That(actual,
Does.Contain("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity"));
Assert.That(actual, Does.Contain(TestScene));
}
}
}
10 changes: 9 additions & 1 deletion Tests/Runtime/Utils/ScenePathFinderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System;
using System.IO;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace TestHelper.Utils
{
Expand All @@ -16,7 +18,11 @@ public class ScenePathFinderTest
[TestCase("Packages/com.nowsprinting.test-helper/**/NotInScenesInBuild.unity")]
public void GetExistScenePath_ExistPath_GotExistScenePath(string path)
{
#if UNITY_EDITOR
const string ExistScenePath = "Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity";
#else
const string ExistScenePath = "NotInScenesInBuild"; // Scene name only
#endif

var actual = ScenePathFinder.GetExistScenePath(path);
Assert.That(actual, Is.EqualTo(ExistScenePath));
Expand All @@ -34,9 +40,11 @@ public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string

[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
public void GetExistScenePath_NotExistPath_ThrowsFileNotFoundException(string path)
[UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)]
public void GetExistScenePath_NotExistPath_InEditor_ThrowsFileNotFoundException(string path)
{
Assert.That(() => ScenePathFinder.GetExistScenePath(path), Throws.TypeOf<FileNotFoundException>());
// Note: Returns scene name when running on player.
}

[TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity")]
Expand Down

0 comments on commit 385d58e

Please sign in to comment.