JG Vimalan's Blog

It is all about coding!

Either DataSourceSettingName or ConnectionString and TableName must be specified and cannot be empty.

I got this error when I compiled  my Coded UI test developed in Visual Studio 2010.

This occured after I added data source to my unit test method.  The test method with data source is as shown below,

[DataSource(“Microsoft.VisualStudio.TestTools.DataSource.XML”, “|DataDirectory|\\Source.xml”, “”, DataAccessMethod.Sequential), DeploymentItem(“TestProject1\\Source.xml”), TestMethod]
        public void CodedUITestMethod1()
        {

To fix this issue, provide valid table name as shown below,

[DataSource(“Microsoft.VisualStudio.TestTools.DataSource.XML”, “|DataDirectory|\\Source.xml”, “EmployeeName“, DataAccessMethod.Sequential), DeploymentItem(“TestProject1\\Source.xml”), TestMethod]
        public void CodedUITestMethod1()
        {

This will fix the issue.

Advertisements

May 17, 2012 - Posted by | C#.NET, Coded UI Test

2 Comments »

  1. This is fine. now I am not getting this error after i add my data source name. Instead I am getting “The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see “Troubleshooting Data-Driven Unit Tests” (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
    Error details: Object reference not set to an instance of an object.”

    The answer would have better if you have specified what an “EmployeeName“ stands for. I am assuming it to Data source name(xml file name)

    Comment by Rekha Vattikuntla | May 22, 2015 | Reply

    • Yeah… I came to know waht it is. “EmployeeName” in the above code means that it is an XML tag in my xml file. Eg: my XML file entries are as follows:

      Rekha
      22
      6
      Testing

      So I will have to replace “EmployeeName” with “Row” like below

      [DataSource(“Microsoft.VisualStudio.TestTools.DataSource.XML”, “|DataDirectory|\\Source.xml”, “Row“, DataAccessMethod.Sequential), DeploymentItem(“TestProject1\\Source.xml”), TestMethod]
      public void CodedUITestMethod1()
      {
      //
      }
      And this fixed my code now 🙂

      Comment by Rekha Vattikuntla | May 22, 2015 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: