質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
NUnit

NUnitとは、JUnitを元に作られた、.NET Framework上で利用できる単体テストの実行支援ツールです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

0回答

1151閲覧

[Unity] Assembly Definition ファイルを追加せずに Plugins 配下のネームスペースにアタッチしたい

rmms

総合スコア1

NUnit

NUnitとは、JUnitを元に作られた、.NET Framework上で利用できる単体テストの実行支援ツールです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2020/07/10 04:32

編集2020/07/13 05:44

前提・実現したいこと

Assets/Plugins 配下のコードのテストをしたい。

ディレクトリ構成

Assets/ Plugins/ CustomServer/ # 独自ライブラリ。Assembly Definition ファイルは配置されていない UriManager/ Model/ CustomUri.cs Tests/ Editor/ Model/ CustomUriTest.cs Tests.asmdef

発生している問題・エラーメッセージ

Assets/Plugins/UriManager/Editor/Tests/Model/CustomUriTest.cs(3,18): error CS0234: The type or namespace name 'Model' does not exist in the namespace 'UriManager' (are you missing an assembly reference?)

該当のソースコード

UriManager/Model/CustomUri.cs

using System using CustomServer; // 独自ライブラリ  namespace UriManager.Model { public class CustomUri { public string Host; public int Port; public CustomServerConfig ServerConfig { get { return CustomServerConfig { Host = Host, Port = Port }; } } public static CustomUri Parse(string uriString) { string[] splitted = uriString.Split(new char[] { ',' }, 2); return new CustomUri { Host = splitted[0], Port = int.Parse(splitted[1]) }; } } }

UriManager/Tests/Editor/Model/CustomUriTest.cs

using System; using NUnit.Framework; using UriManager.Model; using Assert = UnityEngine.Assertions.Assert; namespace UriManager.Editor.Model.Tests { public class CustomUriTest { public CustomUri customUri; [Test] public void Parse() { string urlString = "https://custom.com,8080"; // 正しい Host,Port, の場合 Assert.AreEqual( CustomUri.Parse(urlString), new CustomUri { Host = "https://custom.com", Port = 8080, } ); } } }

UriManager/Tests/Editor/Model/Tests.asmdef

{ "name": "Tests", "references": [], "optionalUnityReferences": [ "TestAssemblies" ], "includePlatforms": [ "Editor" ], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [] }

試したこと

Assembly Definition ファイルを UriManager 配下に配置して riManager/Editor/Tests/Model/Tests.asmdefreferences に追記した。
→ Custom Server 配下への Assembly Definition ファイル配置を促すエラーが発生。
Custom Server は他のライブラリも利用しているため、再帰的に配置していかなければならず現実的ではない。

補足情報(FW/ツールのバージョンなど)

Unity 2018.4.0f1 (都合によりバージョンアップはできない)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問