How does data driven unit test works to retrieve data from VSTS work item? - azure-devops

I saw some test code using data driven test approach to read the test data from VSTS work item with following like code:
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", "https://myaccount.visualstudio.com/DefaultCollection;XXX", "11543012", DataAccessMethod.Sequential)]
I tried this approach also in my code, but got following like error:
The unit test adapter failed to connect to the data source or to read the data. Error details: TF26198: The work item does not exist, or you do not have permission to access it.
I am wondering what is the underlying mechanism of Data Source connection to VSTS work item? How does my code connect to VSTS work item? What credential it uses to access work item?

It uses cache credential of team explorer. Log on test/build with the same account of test agent/build agent, then connect to your VSTS through Team Explorer, then queue build/release to do test.
Note, if you are using Visual Studio Test task, the test is running on build agent, if you are using Run Functional Test, the test is running on test agent.

Related

How can I have robot framework test cases in Visual studio-Test Explorer

I want to link my manual test cases in Azure test plan to robot framework automation test cases( python based test case using selenium library).
Performed below steps :
Created a test project containing my robot framework automated tests.
Checked test project into an Azure DevOps repository.
Created a build pipeline for the project, ensuring that it contains the automated test.
When I executed build pipeline, it appears in Visual Studio - Solution explorer but not in Test Explorer.
enter image description here
My question is how can I get robot framework test cases to appear in VS - Test Explorer so that I can associate it to manual test cases in Azure test plan.
Can you please tell me the steps that I need to do in VS to get Test Scenarios.robot in Test Explorer ?

Azure - Use of dynamically generated Auth-token in Load Test requests

I'm quite new to Azure/AzureDevOps and its LoadTest app.
I need to execute a Load Test for a scenario where I login as a user and execute a few requests while logged in.
The original request is returning auth-token in its Response, that auth-token is used as one of the parameters for the Header in all other sequential Requests.
What I cannot figure out (nor find on the Internet) is to:
1. How to get the auth-token in the 1st Response;
2. How to use this token (dynamically) in all other Requests in the Load Test.
Any help is greatly appreciated.
I guess you intended to run a web test against your web application.
have you created your load test project with Visual Studio?
As for getting the auth-token and using it in other requests,I don't think it is achievable with azure devops load test app.
I believe it should be done in your web test code.
You can create your web test which introduced in this document or write your test in code with selenium or other tools. Add add the web test to a load test project. To deal with the dynamic parameters which cannot be detected by your web request in your test,you can check this document.
After you have created your load test project. You can upload your load test to azure devops load test shown as below pic.

Can I Integrate Web Tests (written in visual studio) in Azure Devops build pipeline

I have a web api (REST) project that is written in .NET and I have written a few webtests (.webtest) that test those apis.
While those tests run fine locally from visual studio, I want to integrate them into my VSTS (Azure Devops) build pipeline, so as to identify and breaking changes that could break any of those APIs.
I am not able to find any task in build pipeline which can run the webtests as part of build. I see option for running unit-tests though.
So, wanted to check what am I missing here.
You might want to find an alternative approach as this link implies it has been deprecated.
Visual Studio web performance test (.webtest file) is tied to the load
test functionality and is deprecated. Some customers have used
.webtest for other purposes such as running API tests, even though it
was not designed for that purpose. Many API testing alternatives are
available in the market. SOAP UI is a free, open source alternative to
consider, and is also available as a commercial option with additional
capabilities.
You could try to use cmd task command line to run MSTest with arguments.
Add Run Command Line step/task to execute MSTest command
Add Publish Test Results step/task
On the other hand, you can do test in Unit Test too, just send the request and check the response, related thread.
Also as Matt mentioned, since Visual Studio web performance tests (.webtest files) are tied to the load test functionality and is also deprecated. You could take a look at this blog here: Cloud-based load testing service end of life

How to start and stop a web application and database in VSO with vNext tasks

I've setup Continuous Integration in my project hosted at Visual Studio Online.
Among other things, I deploy my web application to a test slot and test database and I run integration tests.
However, I don't need the test slot and database to be running all the time. I would like to start them both for the integration tests to run and stop them after my integration tests are done, all automated.
I played around with the Azure PowerShell vNext task, but I couldn't figure out how to accomplish this. Any help would be appreciated. More than the actual answer, I would appreciate a link with more information, if possible.
For the web app slot, you can add AzurePowerShell step in your build defition can create two power-shell script: one start the website via Start-AzureWebsite command before the build start and another one stop the website via Stop-AzureWebsite after the testing is finished.
For the database, you cannot stop it. Refer to this question for details: How do I stop and start a SQL Azure database?

How to run EF migrations when deploying to Azure Website via Visual Studio Online

I have an Azure website configured to deploy from Visual Studio Online (hosted TFS). I'm evaluating the move from Database First model to Code First from Existing Database model.
Currently, As I check-in code to Visual Studio Online, it is deployed to Azure website. How to configure this process to run EF Migrations on the remote (live or test) Azure SQL database when I check-in code to Visual Studio Online.
AFAIK, you need to use the publish profile option to achieve this.
You have to download the publish profile settings file for the website, Import the file in Visual Studio, configure the Execute Code First migrations option and then specify the profile file path in Build Definition used for Continuous deployment.
You can check below post for reference.
http://blogs.msdn.com/b/webdev/archive/2014/04/09/ef-code-first-migrations-deployment-to-an-azure-cloud-service.aspx
I know it is a old post, but I could't find a good answer, so after figure out how to solve it I'm sharing a solution. I work in a project with DDD and N-tiers level. So, it means that the EF isn't in the same project as WebApi, therefore has no option to run migration during the publish wizard. To solve it I have ran update-database directly from package manager console.
Steps:
Acquire the ADO connection string (https://azure.microsoft.com/en-us/documentation/articles/sql-database-connectivity-issues/#connections-to-azure-sql-database)
From package manager console run: Update-database -StartUpProjectName NAMEPROJECTWITHEF -ConnectionString "connection string obtained from item one" -ConnectionProviderName "System.Data.SqlClient"
That's all!
Best Regards,
thiago