Wait for test Case to fully complete

Hi,

I have a UI in which i have multiple plugins and all plugins after getting the result are sending the result to a csv file. Now when iam running my tapPlan , my test is failing randomly because it is not able to access the csv file as it is used by earlier process. So, the issue is that after the verdict is declared test moves to next step but writing to csv file is not finished. so how can i solve this issue that it waits for csv writing to complete and then moves to next step. I dont want to add wait time in all the test steps.
Can someone please advise

Hi @sam836,

It sounds a bit like you are overwriting the previous file when the new test plan runs. In general that might work if you make sure things are not running at the same time. But why don’t you just save in different files?

I want to have a single log file that contains result value for all test steps. I have something like this in my code -
try
{
using (StreamWriter writer = new StreamWriter(new FileStream(@“C:\TestStep.csv”, FileMode.Create, FileAccess.Write)))
{
writer.WriteLine(“-, -, -, -, -”);
writer.Flush();
writer.Close();
}
}
and each plugin after finishing the test use this to write to file. Is there any method that until first one finishes the writing test does not move to next step

Got it. First of all, I don’t think you are disposing the inner FileStream, this might be what is keeping the handle open and blocking other from writing to it - It will only become available after the garbage collector has run which may be a far in the future.

FileMode should probably be Append if you want to write to the end.

Also consider using a system-wide mutex to block processes from accessing the file at the same time.