【问题标题】:Unable to connect to network drive through Nunit-console runner when running tests运行测试时无法通过 Nunit-console runner 连接到网络驱动器
【发布时间】:2019-06-25 04:48:36
【问题描述】:

所以我这里有这几行代码-

// on a network location
string fileName = @"S:\Information Technology\QA\Automation\jsons\scheduler_ready\patientInfo.json";
            string json = TestHelper.GetJsonFromFilePath(fileName);
            patient = TestHelper.ExtractJsonData(json);

我有一个依赖于从 JSON 获取信息的 NUnit 测试。我遇到的问题是执行。当我通过 Visual Studio 运行时,我可以很好地读取文件路径。但是当我通过 NUnit-Console 运行程序执行时,我收到一个错误,提示 json 的“部分文件路径未找到”。

我进行了研究,但到目前为止还没有运气。有没有人接触过这个问题?

我是否需要采取额外的步骤来告诉控制台是我的用户正在访问此文件位置?

编辑

我将文件路径更改为本地位置。看来我无法通过 nunit-console 运行器访问网络驱动器。有没有办法做到这一点?

【问题讨论】:

  • nunit-console 是作为不同的用户运行还是在不同的用户会话中运行?
  • 根据您运行 nunit-console 的方式,S 驱动器可能存在也可能不存在。要找出答案,请编写一个枚举驱动器号并将其写入控制台的测试。

标签: c# selenium-webdriver nunit nunit-console


【解决方案1】:

json 文件是解决方案目录的一部分吗?如果是,可以动态格式化:

string fileName = $@"{folderPath}\Automation\jsons\scheduler_ready\patientInfo.json";
            string json = TestHelper.GetJsonFromFilePath(fileName);
            patient = TestHelper.ExtractJsonData(json);

您可以使用以下值之一获取文件夹路径:

System.Reflection.Assembly.GetEntryAssembly().Location;
AppDomain.CurrentDomain.BaseDirectory
Assembly.GetEntryAssembly().Location

【讨论】:

  • 没有。 json 位于共享网络驱动器上。但是,当我将其更改为解决方案目录时,这很有效。但是有没有办法通过控制台运行器访问网络驱动器?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多