在Visual Studio 2010 里使用Nunit 进行Debug 测试
1. 創建帶測試類庫的項目解決方案(詳細方法參見Nunit Quick Start),如圖:
?
下面一個是供Nunit 進行單元測試的。
2 選中測試類庫,鼠標右鍵選擇屬性,調試
在啟動操作 選項中,選擇啟動外部程序,并設置好Nunit 單元測試 Nunit.exe程序位置
3 打開 Nunit 安裝目錄,找到Nunit.exe.config
修改配置文件如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
? <!--
?? The GUI only runs under .NET 2.0 or higher. The
?? useLegacyV2RuntimeActivationPolicy setting only
?? applies under .NET 4.0 and permits use of mixed
?? mode assemblies, which would otherwise not load
?? correctly.
? -->
? <startup useLegacyV2RuntimeActivationPolicy="true">
??? <!-- Comment out the next line to force use of .NET 4.0
??? <supportedRuntime version="v2.0.50727" />
??? <supportedRuntime version="v4.0.30319" /> -->
??? <requiredRuntime version="v4.0.30319" /> <!--添加該行配置,并只留這一個配置-->
? </startup>
? <runtime>
??? <!-- Ensure that test exceptions don't crash NUnit -->
??? <legacyUnhandledExceptionPolicy enabled="1" />
??? <!-- Run partial trust V2 assemblies in full trust under .NET 4.0 -->
??? <loadFromRemoteSources enabled="true" />? <!--該項配置為true-->
??? <!-- Look for addins in the addins directory for now -->
??? <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
????? <probing privatePath="lib;addins" />
??? </assemblyBinding>
? </runtime>
</configuration>
?
4? 為要測試的方法打上斷點,選中測試類庫為啟動項,按F5運行
??
在Nunit 界面上運行要測試的方法,成功在斷點上停下來
轉載于:https://www.cnblogs.com/iampkm/archive/2012/10/10/2718088.html
總結
以上是生活随笔為你收集整理的在Visual Studio 2010 里使用Nunit 进行Debug 测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学英语不必太在意单词
- 下一篇: putty的设置