CodedUI Test Does Not Read Data from CSV Input File

I'm having difficulty displaying a CSV file using the coded interface testing method. This is most likely a stupid question, but I cannot find a solution to my problem, at least not the one that works. I have definitely set the CSV file property to Copy always . I also imported the CSV file by writing the following line above the testing method.

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Data\\login.csv", "login#csv", DataAccessMethod.Sequential), DeploymentItem("login.csv"), TestMethod]

The name of the file login.csvand is in the folder Data.

The test will be compiled without any problems, but as soon as the test completes the fields that should receive input from the CSV file, they remain empty and execution is interrupted. I tried replacing the data from the CSV file with Strings and it works fine. Part of the code that I use to import each parameter:

TestContext.DataRow["Username"].ToString()

In addition, the CSV file contains something in the following lines:

Username,Password,Fullname
admin@mail.com,password,Admin

Is there anyone who can indicate that I forgot.

Update: I pointed out the problem, it seems the problem only revolves around the first column in the csv file. When I try to import any other values, it works fine.

+3
source share
3 answers

(BOM). CSV . CSV , Notepad ++. DataRow.ItemArray[...] . DataRow.Table.Columns.ResultsView[...] , .

CSV Visual Studio Solution Explorer = > Add = > New item = > # = > General = > . Microsoft Excel CSV, . Notepad ++ CSV, . , Visual Studio , CSV .

enter image description here


Visual Studio . " 2 - " Microsoft . ( Holistic Developer .):

  1. CSV , . FILE " " "" (UTF-8 ) - Codepage 65001 .
+8

Visaul Studio 2010 , " 1252" (Windows) - Codepage 1252 ".

: Visual Studio 2010 CSV. > "" > " " > " (Windows) - Codepage 1252" > "".

.

+1

, . - , , , .

- , .

0

Source: https://habr.com/ru/post/1539251/


All Articles