[英]System.UnauthorizedAccessException when running a test in VS2008
When I run selenium tests (written as nunit tests) from VS2008 I am getting: 当我从VS2008运行硒测试(写为nunit测试)时,我得到:
System.UnauthorizedAccessException : Access to the path /bin/Debug is denied.
System.UnauthorizedAccessException:拒绝访问/ bin / Debug路径。
The test is trying to read an entry in App.Config. 测试正在尝试读取App.Config中的条目。 This file is copied to bin/Debug during compilation.
该文件在编译期间复制到bin / Debug。
I used unlocker to check file handles and it is VS2008 that has a handle to that file. 我使用解锁器来检查文件句柄,而VS2008具有该文件的句柄。
You need to change your test configuration so that access to the directory is allowed. 您需要更改测试配置,以便允许访问目录。 See Test/Edit Test Run Configurations/Deployment.
请参阅测试/编辑测试运行配置/部署。
If you are trying to read or write a file in that directory, you will probably need to copy it to the directory where the test is run. 如果您尝试在该目录中读取或写入文件,则可能需要将其复制到运行测试的目录中。 Again, the Deployment tab of the test run config dialog will help you out.
同样,测试运行配置对话框的“部署”选项卡将帮助您。
I was having the same problem. 我遇到了同样的问题。 The way I got around it was by starting Visual Studio with Administrator privileges (right click on visual studio --> run as Administrator).
我解决该问题的方法是通过以管理员权限启动Visual Studio(右键单击Visual Studio->以管理员身份运行)。 I then re-opened the solution and ran my tests.
然后,我重新打开解决方案并运行测试。 This time they passed.
这次他们过去了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.