3
votes

I am usimg VS 2010 Professional.And want to connect the TFS Testcase datasource without using MTM(Microsofot Test Manager).Is it Possible to do so.

  [DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase",
                "http://TFS URL", "27211",
                DataAccessMethod.Sequential), TestMethod] 
    public void CheckUserLogin()
    {
        PageObjects.BrowserInvoke();
        PageObjects.TextBox(UIMapRepository.userName,   TestContext.DataRow["UserName"].ToString());
        PageObjects.TextBox(UIMapRepository.passWord, TestContext.DataRow["Password"].ToString());
        PageObjects.ButtonClick(UIMapRepository.loginButton);
        Assert.AreEqual("Logout", PageObjects.CheckElementExist(UIMapRepository.logoutButton));
        PageObjects.ButtonClick(UIMapRepository.logoutButton);
        PageObjects.CloseBrowser();
    }

When I run this I get 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: TF30063: You are not authorized to access tfs. The remote server returned an error: (401) Unauthorized.

1
What format is the TFS URL you are supplying? Also, are you able to access your project in Team Explorer in Visual Studio (eg. connect to project)?Nashibukasan
tfs.company.com:8080/tfs/aps;Project".Yes I am able to connect to TFS directly and I have taken the Url from Team explorer TFS Properties.Pat
FYI, I got a similar error when creating a coded UI test from an action recording recorded with Microsoft Test Manager on the hosted TFS 2012.John Saunders
Are you running these tests locally or on a remote machine?Nashibukasan

1 Answers

1
votes

Can not connect to Team Foundation Service data source for coded ui tests has a similar issue.

I suspect you'll need to pass the authentication credentials along with the URL in the TFS connection string.

How do you connect to a TFS server in C# using specific credentials? shows how to connect programmatically. You should be able to wrap that into a format that the DataSource attribute will accept.