MSTest 測試專案寫入 log === 一般寫 log ``` c# Assert.AreEqual(true, false, "++產生錯誤訊息++"); ```  如果把 false 改成 true  將會看不到 log 運用上限制蠻多的 所以自己寫了一個 log 來整理 output 輸出格式 安裝 MSTestLog 的 NuGet 套件 記得在測試專案上呼叫 MSTestLog.Initialize() 初始化 MSTestLog 這個類別庫 ``` c# using MSTestTool; [TestClass] public class UnitTest3dData { [TestInitialize] public virtual void Initialize() { MSTestLog.Initialize(); } } ``` 使用上可以在任何地方寫 log ``` c# MSTestLog.WriteLine("++產生錯誤訊息 1++"); MSTestLog.WriteLine("++產生錯誤訊息 2++"); ```  點擊「Output」  就可以看到多個 log 與 Assert 混用 ``` c# Assert.AreEqual(true, false, MSTestLog.WriteLine("++產生錯誤訊息++")); ``` 點擊「Output」  就可以看到 log  ###### tags: `MSTest`
×
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