Mor*_*ral 15 .net c# nunit windows-8 windows-store-apps
我目前正在为一个类的Windows应用商店应用程序(Windows 8)工作,我在运行NUnit测试时遇到问题.
我的解决方案/项目设置如下所示:
TheMetroApp.sln
杂项.依赖性和实用性
UnitTests依赖于并引用DataModel.DataModel依赖于并引用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
}
Run Code Online (Sandbox Code Playgroud)
TheMetroApp是Windows 8 SDK示例项目之一,但引入了一些自定义XAML表单.我对此项目没有任何问题.
我的问题是我尝试使用的单元测试运行器都没有工作.
当我尝试使用官方NUnit x86测试运行器(版本2.6.1)时,我的测试因证书相关问题而失败(请参阅此处):
UnitTests.TaskSourceTests.CreateTaskTest:
SetUp : System.InvalidOperationException : The process has no package identity. (Exception from HRESULT: 0x80073D54)
Run Code Online (Sandbox Code Playgroud)
ReSharper的NUnit测试运行器出于同样的原因失败.不幸的是,它看起来似乎没有解决方法.
我也尝试使用Visual Studio 2012中内置的测试运行器(通过NUnit Visual Studio测试适配器).当我尝试使用"全部运行"运行我的测试时,我得到以下输出:
------ 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) ==========
Run Code Online (Sandbox Code Playgroud)
我注意到一些奇怪的事情是,如果我在测试资源管理器中选择一个特定的测试并告诉它运行,我会得到一个略有不同的错误消息:
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.
Run Code Online (Sandbox Code Playgroud)
这有点令人困惑,因为我安装了NUnit测试适配器.我没有在测试适配器的启动板页面上看到与我的问题类似的任何内容.
我不确定我应该从哪里开始.如果这不起作用,我不介意重新设计我的项目以使用xUnit.net,Microsoft的单元测试框架或其他东西.如果我能让NUnit工作,那将是非常棒的.
谢谢!
我有一个 Windows 7 Phone 应用程序,它遇到了与您相同的问题。我的解决方案是创建一个单独的“链接”项目,该项目使用标准 .net 库编译代码。链接的项目在单元测试/NUnit 方面不会有任何问题。
请参阅以下内容了解更多信息:
http://msdn.microsoft.com/en-us/library/ff921109(v=pandp.40).aspx
http://visualstudiogallery.msdn.microsoft.com/5e730577-d11c-4f2e-8e2b-cbb87f76c044/
我已将该应用程序移植到 Windows 8,并且运行我的测试用例没有任何问题。
| 归档时间: |
|
| 查看次数: |
3724 次 |
| 最近记录: |