# Unity 單元測試目錄規範與建立 ## 插件目錄與單元測試目錄 ### 以插件為例:  ### 於插件中建立單元測試目錄:  --- ## 建立 Tests Assembly ### 依照插件名稱對應創建 Tests Assembly Editor.Tests (**PluginMaker.Editor.Tests = 插件名稱.Editor.Tests**)。  Runtime.Tests (**PluginMaker.Runtime.Tests = 插件名稱.Runtime.Tests**)。  --- ## 配置 Tests Assembly ### Editor.Tests  ### Runtime.Tests Define Constraints **(透過宏的限制,以防編譯)** ``` // 可自定義 UNITY_INCLUDE_TESTS ``` 另外,如果有部分測試代碼想要編譯,如下: ``` #if UNITY_INCLUDE_TESTS // 允許編譯的 Tests 代碼 #endif ```  --- ## 開始編寫簡單的單元測試 ### 建立 Tests 腳本  ### 建議腳本以 Tests 結尾 -> MyFirst**Tests**.cs   --- ## 執行單元測試 ### 開啟 Test Runner  ### 運行測試結果 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up