現在、Windows Storeアプリケーション(Windows 8)でクラスを作成しており、NUnitテストを実行する際に問題が発生しています。NUnitを使ってWindows 8 Store Appをテストする
私のソリューション/プロジェクトの設定には、次のようになります。
TheMetroApp.sln
- のSQLite-net.csproj - クラスライブラリ(Windowsストアアプリ)。ファイルはNuGetから取得されます。
- DataModel.csproj - クラスライブラリ(Windowsストアアプリケーション)
- UnitTests.csproj - ユニットテストライブラリ(Windowsストアアプリケーション)。 NUnitフレームワークはNuGetから引き出されます。
- TheMetroApp.csproj - Windows SDKのサンプルの1つから取得されたプロジェクトファイル。
その他。依存関係およびユーティリティ
- のWindows 8 ProのRTM/Visual Studioの2012 RTM
- ReSharperの7
- NUnitの2.6.1
- のSQLite(指示hereごとに設定します)
UnitTestsはDataModelに依存し、参照します。 DataModelはSQLite-netに依存し、SQLite-netを参照します。私がUnitTestsプロジェクトに追加した唯一のものは、スタブNUnit単体テストを含む単一のクラスです。私の知る限り、これらが正しく設定されています。
[TestFixture]
public class TaskSourceTests
{
#region Private Class Members
private ITaskSource _taskSource;
private String _dbPath;
#endregion
#region Testing Infrastructure
[SetUp]
public void SetUp()
{
// This part makes NUnit/ReSharper have problems.
_dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "UnitTestDatabase.sqlite");
}
#endregion
#region Misc. CRUD stuff
[Test]
public void CreateTaskTest()
{
// Save the task.
Task task = new Task("Some Task", "lol.", DateTime.Now, false);
_taskSource.Save(task);
// Confirm that it is in the task db.
using(SQLiteConnection db = new SQLiteConnection(_dbPath))
{
const String query = "SELECT * FROM Task WHERE Id = ?";
IList<Task> results = db.Query<Task>(query, task.Id);
Assert.True(results.Contains(task));
}
}
// ...and so on [but with stubs that are basically Assert.Fail("")].
#endregion
}
TheMetroAppは、Windows 8 SDKサンプルプロジェクトの一つであるが、私はこのプロジェクトに問題を持っていないよに投げいくつかのカスタムXAMLフォームで。
私の問題は、私が使用しようとしているユニットテストランナーのどれも働いていないことです。
私は公式のNUnitのx86テストランナー(バージョン2.6.1)を使用しようとすると、私のテストでは、証明書関連の問題(see here)による失敗:
UnitTests.TaskSourceTests.CreateTaskTest:
SetUp : System.InvalidOperationException : The process has no package identity. (Exception from HRESULT: 0x80073D54)
のReSharperのNUnitのテストランナーがまったく同じ理由で失敗しました。残念ながら、現時点では回避策がないように見えます。
また、Visual Studio 2012に組み込まれているテストランナー(NUnit Visual Studio Test Adapter)を使用してみました。私は「すべて実行」を使用して私のテストを実行しようとすると、私は次のような出力が得られます。私は気づいた奇妙な
------ Run test started ------
Updating the layout...
Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete. Full package name: "GibberishAndStuff"
No test is available in C:\Projects\project-name\ProjectName\UnitTests\bin\Debug\UnitTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
========== Run test finished: 0 run (0:00:09.4873768) ==========
何かが私は、私がテストエクスプローラで特定のテストを選択して実行するように指示した場合ということです
Could not find test executor with URI 'executor://nunittestexecutor/'. Make sure that the test executor is installed and supports .net runtime version 4.0.30319.18010.
これは、NUnitテストアダプターがインストールされているため、これは難しいことです。私は、テストアダプターのランチパッドページで私の問題に似た何かを見ていません。
私はここからどこへ進んでいくべきかわかりません。これがうまくいかない場合は、xUnit.net、Microsoftの単体テストフレームワークなどを使用するプロジェクトを修正しても構いません。私がNUnitを動作させることができればかなり素晴らしいでしょう。
ありがとうございます!
これは良い質問です。これは、リフレクトモデルと.NETCoreとの互換性が古典的な.NETのために仮定しています。また、Windowsデスクトップモードで.NETCoreアプリケーションを読み込むことができるかどうかはわかりません。この記事では、その違いについて説明します:http://blogs.msdn.com/b/dotnet/archive/2012/08/28/evolving-the-reflection-api.aspx – Robert