0

So I have these lines of code right here-

// 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);

I have a NUnit test that relies on these getting information from a JSON. The issue I'm having is the execution. When I run through Visual Studio, I can read the filepath just fine. But when I execute through NUnit-Console runner, I get an error that says "part of file path not found" for the json.

I researched and so far no luck. Has anyone come into contact with this problem?

Do I need to take extra steps to tell the console that it is my user that is accessing this file location?

EDIT

I changed my file path to a local location. It seems I can't access a network drive through the nunit-console runner. Is there a way to accomplish this?

Krazy Dev
  • 184
  • 3
  • 16
  • Is nunit-console being run as a different user or in a different user session? – yaakov Jun 25 '19 at 05:34
  • Depending on how you run nunit-console, the S drive may or may not exist for it. To find out, write a test that enumerates the drive letters and writes them to the console. – Charlie Jun 25 '19 at 08:52

1 Answers1

0

Is the json file part of the solution directory? If it is, you can dynamically format it:

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

You can get the folder path with one of these values:

System.Reflection.Assembly.GetEntryAssembly().Location;
AppDomain.CurrentDomain.BaseDirectory
Assembly.GetEntryAssembly().Location
  • No. The json is on a shared network drive. This worked when I changed it to a solution directory though. But is there a way to access the network drive through the console runner? – Krazy Dev Jun 25 '19 at 05:15