ReSharper 单元测试未在 bin 目录中运行 [英] ReSharper Unit Test not run in bin directory

查看:56
本文介绍了ReSharper 单元测试未在 bin 目录中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

序言

我知道,这个问题似乎在这里有答案:

  • Visual Studio 配置

    Microsoft Visual Studio Ultimate 2012

    版本 11.0.61219.00 更新 5

    微软 .NET 框架

    版本 4.6.01038

    安装版本:终极版

    • 架构和建模工具 04940-004-0038003-02857
    • Visual Studio 2012 团队资源管理器 04940-004-0038003-02857
    • 适用于 Visual Studio 2012 的 Microsoft 团队资源管理器
    • Visual Basic 2012 04940-004-0038003-02857
    • Microsoft Visual Basic 2012
    • Visual C# 2012 04940-004-0038003-02857
    • Microsoft Visual C# 2012
    • Visual C++ 2012 04940-004-0038003-02857
    • Microsoft Visual C++ 2012
    • Visual F# 2012 04940-004-0038003-02857
    • Microsoft Visual F# 2012
    • Windows Phone SDK 8.0 - DEU 04940-004-0038003-02857
    • Windows Phone SDK 8.0 - DEU
    • ASP.NET 和 Web 工具 2012.3.41009
    • 生成单元测试 1.0
    • Git 源代码控制提供程序 1.0.0.0
    • JetBrains ReSharper Ultimate 10.0.2 内部版本 104.0.20151218.120627
    • 适用于 Windows Phone 6.2.923.0 的微软广告 SDK
    • Microsoft Advertising SDK for Windows Phone Build 6.2.923.0
    • 微软 XNA 游戏工作室 4.0
    • 微软 XNA 游戏工作室 4.0
    • NuGet-Paket-Manager 2.8.60318.667
    • PreEmptive Analytics Visualizer 1.0
    • SQL Server 数据工具 11.1.20627.00
    • Microsoft SQL Server 数据工具
    • Git 扩展

    解决方案

    您没有列出已安装的任何 NUnit 版本,但是您标记了这个nunit",所以我假设您正在使用它!此外,我假设 NUnit >= 3.0 ... 否则请忽略这一点.:-)

    NUnit 3.0 停止更改当前目录.无论如何,这样做对我们来说是个坏主意,而且在 3.0 中这真的个坏主意,因为不同目录中的多个程序集可能同时运行.

    因此,假设它仍然是 NUnit 问题,而不是使用相对路径,而是使用 TestContext.CurrentContext.TestDirectory 作为文件的位置.

    Preamble

    I know, that this question seems to have anwsers here:

    I have nearly the same problem like ReSharper 10 test runner failing to find AppSettings referenced from external file. But these answer stated, that the problem should be gone with ReSharper 10.0.2

    Question

    I included a custom.xml files with custom settings, and I need to read them from my unit test. But my file is not found.

    I looked, where the process runs, and included this line

    var curdir = Directory.GetCurrentDirectory();
    

    So I found out, that curdir is C:\\Users\\MYUSER\\AppData\\Local\\JetBrains\\Installations\\ReSharperPlatformVs11_000

    Now it is obvious that my file cannot be found. After googling it, it found the above mentioned questions. But none of these solutions works for me.

    These are my settings:

    Visual Studio Configuration

    Microsoft Visual Studio Ultimate 2012

    Version 11.0.61219.00 Update 5

    Microsoft .NET Framework

    Version 4.6.01038

    Installierte Version: Ultimate

    • Architecture and Modeling Tools 04940-004-0038003-02857
    • Team Explorer für Visual Studio 2012 04940-004-0038003-02857
    • Microsoft Team Explorer für Visual Studio 2012
    • Visual Basic 2012 04940-004-0038003-02857
    • Microsoft Visual Basic 2012
    • Visual C# 2012 04940-004-0038003-02857
    • Microsoft Visual C# 2012
    • Visual C++ 2012 04940-004-0038003-02857
    • Microsoft Visual C++ 2012
    • Visual F# 2012 04940-004-0038003-02857
    • Microsoft Visual F# 2012
    • Windows Phone SDK 8.0 - DEU 04940-004-0038003-02857
    • Windows Phone SDK 8.0 - DEU
    • ASP.NET and Web Tools 2012.3.41009
    • GenerateUnitTest 1.0
    • Git Source Control Provider 1.0.0.0
    • JetBrains ReSharper Ultimate 10.0.2 Build 104.0.20151218.120627
    • Microsoft Advertising SDK for Windows Phone 6.2.923.0
    • Microsoft Advertising SDK for Windows Phone Build 6.2.923.0
    • Microsoft XNA Game Studio 4.0
    • Microsoft XNA Game Studio 4.0
    • NuGet-Paket-Manager 2.8.60318.667
    • PreEmptive Analytics Visualizer 1.0
    • SQL Server Data Tools 11.1.20627.00
    • Microsoft SQL Server Data Tools
    • Git Extensions

    解决方案

    You don't list any version of NUnit installed, but you tagged this 'nunit' so I'm going to make an assumption you are using it! Further, I'm assuming NUnit >= 3.0... ignore this if otherwise. :-)

    NUnit 3.0 stopped changing current directory. It's a bad idea for us to do that anyway and it's a really bad idea with 3.0, when multiple assemblies in differing directories may be running at the same time.

    So, assuming still it's an NUnit problem, instead of using a relative path, use TestContext.CurrentContext.TestDirectory as the location of your file.

    这篇关于ReSharper 单元测试未在 bin 目录中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆