我面臨UnitTest的問題。我想測試使用基於NPoco的存儲庫完成的數據訪問。因此,我寫了一些測試,測試項目通過NuGet檢索NUnit,NPoco,System.Data.SQLite和其他一些東西。當使用NUnit執行測試時未找到System.Data.SqLite DataProvider
這是TestProject的的app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="RepositoryTests.Properties.Settings.ConnectionString" connectionString="Data Source=db.sqlite;Version=3" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
在VS,項目構建的罰款。在Visual Studio中觸發測試也可以。
使用MSBUILD構建項目也很有用。與msbuild.exe他們建設運行後通過NUnit的測試提出了一個例外,但:
這只是個案,執行直接使用NUnit測試時(某事像nunit-console.exe myproject.csproj /config:Release
)。在VS中觸發它們不成問題。
有誰知道如何解決這個問題?
感謝您的回答,但不幸的是您提供的代碼沒有辦法。但我會對它進行投票,因爲帶有nunit-config-file-problem的提示最終會導致(hacky)解決方案。 – nozzleman