Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to use Application.temporaryCachePath in tests if possible #111

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Editor/OpenPersistentDataPathMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TestHelper.Editor
/// </summary>
public static class OpenPersistentDataPathMenu
{
[MenuItem("Window/Open Persistent Data Directory")]
[MenuItem("Window/Test Helper/Open Persistent Data Directory")]
private static void OpenPersistentDataPathMenuItem()
{
EditorUtility.RevealInFinder(Application.persistentDataPath);
Expand Down
21 changes: 21 additions & 0 deletions Editor/OpenTemporaryCachePathMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023-2024 Koji Hasegawa.
// This software is released under the MIT License.

using UnityEditor;
using UnityEngine;

namespace TestHelper.Editor
{
/// <summary>
/// Open temporary cache directory in the Finder.
/// <see href="https://docs.unity3d.com/ScriptReference/Application-temporaryCachePath.html">Application.temporaryCachePath</see>
/// </summary>
public static class OpenTemporaryCachePathMenu
{
[MenuItem("Window/Test Helper/Open Temporary Cache Directory")]
private static void OpenTemporaryCachePathMenuItem()
{
EditorUtility.RevealInFinder(Application.temporaryCachePath);
}
}
}
3 changes: 3 additions & 0 deletions Editor/OpenTemporaryCachePathMenu.cs.meta

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

14 changes: 8 additions & 6 deletions Tests/Editor/JUnitXml/JUnitXmlWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
using NUnit.Framework;
using TestHelper.Comparers;
using TestHelper.Editor.TestDoubles;
using UnityEngine;

namespace TestHelper.Editor.JUnitXml
{
[TestFixture]
public class JUnitXmlWriterTest
{
private const string TestResourcesPath = "Packages/com.nowsprinting.test-helper/Tests/Editor/TestResources";
private const string TestOutputDirectoryPath = "Logs/TestHelper/JUnitXmlWriterTest";
// Note: relative path from the project root directory.

private readonly string _testOutputDirectoryPath =
Path.Combine(Application.temporaryCachePath, TestContext.CurrentContext.Test.ClassName);

[Test, Order(0)]
public void WriteTo_CreatedJUnitXmlFormatFile()
{
if (Directory.Exists(TestOutputDirectoryPath))
if (Directory.Exists(_testOutputDirectoryPath))
{
Directory.Delete(TestOutputDirectoryPath, true);
Directory.Delete(_testOutputDirectoryPath, true);
}

var nunitXmlPath = Path.Combine(TestResourcesPath, "nunit3.xml");
var result = new FakeTestResultAdaptor(nunitXmlPath);
var path = Path.Combine(TestOutputDirectoryPath, TestContext.CurrentContext.Test.Name + ".xml");
var path = Path.Combine(_testOutputDirectoryPath, TestContext.CurrentContext.Test.Name + ".xml");
JUnitXmlWriter.WriteTo(result, path);

Assume.That(path, Does.Exist);
Expand All @@ -40,7 +42,7 @@ public void WriteTo_ExistFile_OverwriteFile()
{
var nunitXmlPath = Path.Combine(TestResourcesPath, "nunit3.xml");
var result = new FakeTestResultAdaptor(nunitXmlPath);
var path = Path.Combine(TestOutputDirectoryPath, TestContext.CurrentContext.Test.Name + ".xml");
var path = Path.Combine(_testOutputDirectoryPath, TestContext.CurrentContext.Test.Name + ".xml");

// Destroy the output destination file.
File.Copy(nunitXmlPath, path, true);
Expand Down
Loading