Resharper runs UnitTest from different location

前端 未结 10 714
清歌不尽
清歌不尽 2020-12-01 15:46

When I run unit tests with Visual Studio it works fine, because it runs from project directory where all assemblies are. But when I run it with resharper it

相关标签:
10条回答
  • 2020-12-01 16:19

    If you have run and build problem after disabling of "shadow build" you must first choose "Clean all" from Build option and after that build your project on "shadow build" disable

    0 讨论(0)
  • 2020-12-01 16:23

    In the documentation for NUnit's Gui Test Runner settings has the following note about Shadow Copy

    Note: If you are tempted to disable shadow copy in order to access files in the same directory as your assembly, you should be aware that there are alternatives. Consider using the Assembly.Codebase property rather than Assembly.Location.

    Here is an example of using the Assembly.Codebase property

        private string AssemblyLocation()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var codebase = new Uri(assembly.CodeBase);
            var path = codebase.LocalPath;
            return path;
        }
    
    0 讨论(0)
  • What solved it for me was to set the "Copy Local" property to true on the nunit.framework.dll reference in the test project.

    0 讨论(0)
  • 2020-12-01 16:25

    You are loading your assemblies dynamically by using Assembly.Load(). May be you are missing a reference to the assembly to load. Otherwise shadow-copying may miss the unreferenced assemblies.

    If you do not want to reference these assemblies, be sure to include them in your project and copy them to the output directory. You can do so by setting the "Copy to Output Directory" property or creating a custom post-build step.

    0 讨论(0)
提交回复
热议问题