0

I'm trying to load test our application at work and I have created a web-test (coded web-test) that works perfectly locally.

It uses a helper class to create data that's required for the application like name, email etc (which must be unique for each application).

Name is returned by a method that resides in helper class as an object of Name class which is pretty basic contains 2 props First and Last.

public static Name GetRandomName()
{
    // if (!File.Exists(@"..\..\..\Apps-Load-Performance-Tests\Data Files\fNames_1.csv")) return new Name();

    var allLines = File.ReadAllLines(@"..\..\..\Apps-Load-Performance-Tests\Data Files\fNames_1.csv");
    var maxLength = allLines.Length;
    var random = new Random();
    return new Name
    {
        First = allLines[random.Next(maxLength)],
        Last = allLines[random.Next(maxLength)]
    };
}

Problem is when I run a load test via Visual Studio cloud - it throws FileNotFoundException (fNames_1.csv)

In my test settings - I have 'Enable Deployment' checked and added the .csv file and the directory that contains the .csv file... but that doesn't seem to solve the problem.

I also tried adding [DeploymentItem()] attribute but no go...

What am I doing wrong? Any help or if someone can point me to right direction - I'd highly appreciate it.

Thanks in advance!

Johny
  • 387
  • 1
  • 7
  • 20

1 Answers1

1

Deployment via the options listed in the question copies files into the TestResults\{{name+datetime+etc}}\Out directory for the test run. The relative path in the question appears to be expecting the Apps-Load-Performance-Tests directory to be in the same directory as TestResults, or even closer to the root directory.

For a cloud load test the files need to be deployed to the cloud computer that runs the test and into the same directories as the other parts of the deployed test. I suggest changing the directory paths in the GetRandomName method and related code to expect the files to be in the TestResults\...\Out directory for the run. Also make sure the files are deployed to there.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
  • thanks! Thats what it was - when test is run on the cloud it wasn't able to find the file at that path defined. So what I ended up doing was @"/filename.csv" for local execution and @"filename.csv" for cloud (notice the slash - without slash it won't work on local execution -- weird) Thanks again for your help and your time! Cheers – Johny Feb 27 '18 at 02:59
  • I am facing the same problem. Where exactly should I keep the file in my project so that while running the tests the file can be found? – Shridhar R Kulkarni May 02 '19 at 09:08
  • 1
    @ShridharRKulkarni Put it in one of the directories in your solution and make sure that the file is deployed. – AdrianHHH May 02 '19 at 13:31