Where is test result stored in MTM 2010? - microsoft-test-manager

I am trying to provide a copy of the test result recorded using MTM 2010 to client, do you know where to grab the result?
Thanks.

The test run and its attachments are stored on the TFS server and available via the TFS SDK. See the TestManagementService apis where ITestRun.Attachments would contain all test run associated attachments
var testsvc = tfs.GetService<TestManagementService>()
IEnumerable<ITestRun> testRun = testsvc.GetTeamProject("myteamprojectname").TestRuns; // you can use the query/find

I follow either of below mentioned two ways to analyze my test runs :
Run following command from "Run":
start mtm://[tfsserver:portnumber/tfs/collectionname]/p:[teamproject]/testing/testrun/open?id=
downloading results file (.trx) to my local system:
tcm run /export /id:id /resultsfile:[my_local_path] /collection:CollectionURL /teamproject:project [/login:username,[password]] [/attachment:attachmentname]

Related

How to read .runsettings test parameter in xUnit fixture

I'm writing xUnit unit test cases for a dotnet core application which uses DocumentDB (CosmosDB) as storage. The unit test are written to execute against the local cosmos db emulator. On the Azure DevOps build environment, I've setup the Azure Cosmos DB CI/CD task which internally creates a container to install the emulator. However, I'm not able to figure out that how the endpoint of emulator can be passed to xUnit fixture?
Is there any way through which xUnit fixture can read the .runsettings test parameters or parameters can be passed via other source?
Update
Currently, I implemented the scenario using Environment Variable but still not happy to define the connection string as a environment variable using powershell in build task and read it in through code during unit test execution. I was thinking if there could be another way of achieving it..
Below snapshot shows how the build tasks are configured currently as workaround to achieve the desired:
And code to read the value as
var serviceEndpoint = Environment.GetEnvironmentVariable("CosmosDbEmulatorEndpointEnvironmentVariable");
Since, UnitTest task provides the option to pass .runsettings/.testsettings with option to override the test run parameters so was thinking it something can be achieved using those options.
This is not supported in xUnit.
See SO answers here and here, and this github issue indicating that it is not something that will be supported in xUnit.
Currently, I implemented the scenario using Environment Variable but still not happy to define the connection string as a environment variable using powershell in build task and read it in through code during unit test execution. I was thinking if there could be another way of achieving it..
Below snapshot shows how the build tasks are configured currently as workaround to achieve the desired:
And code to read the value as
var serviceEndpoint = Environment.GetEnvironmentVariable("CosmosDbEmulatorEndpointEnvironmentVariable");
Since, UnitTest task provides the option to pass .runsettings/.testsettings with option to override the test run parameters so was thinking it something can be achieved using those options.

Can i have Test execution (Robot FR) statistics as custom statistics chart in teamcity statistics Tab?

i'm trying to display test results statistics in the statistics tab in Teamcity, so i will be able to see if a test is always failed (for example) via the static chart.
I'm not trying to have dashboard of the last tests executed (LINK) can't help me.
I can't use Robot Framework listeners because i use scheduletask on the remote machine to run test cases.
Any suggestions?
Solved by using the : "Providing data using the teamcity-info.xml file" here
after creating the "teamcity-info.xml" file in the root of the build, i create a custom chart with the keys : chart1Key / chart2Key (existing in the "teamcity-info.xml" file). So i will be able to see the OK/KO tests percents.
Find here the Result

Deploy different seed data for different publish profiles using visual studio ssdt?

Is it possible to deploy different sets of seed data for different publish profiles using visual studio Sql Server Data tools database project?
We know you can deploy seed data using a post deployment script.
We know you can deploy to different environments using the publish profiles facility.
What we don't know is how you can deploy different seed data to the different environments.
Why would we want to do this?
We want to be able to do this so we can have a small explicit set of seed data for unit testing against.
We need a wider set of data to deploy to the test team's environment for the test team to test the whole application against
We need a specific set of seed data for the pre-prod environment.
There are a few ways you can achieve this, the first approach is to check for the environment in the post deploy script such as..
if ##servername = 'dev_server'
begin
insert data here
end
A slightly cleaner version is to have different script files for each environment and importing them via the :r import sqlcmd script so you could have:
PostDeploy.sql
DevServer.sql
QAServer.sql
then
if ##servername = 'dev_server'
begin
:r DevServer.sql
end
if ##servername = 'qa_server'
begin
:r QAServer.sql
end
You will need to make sure the paths to the .sql files are correct and you copy them with the dacpac.
You don't have to use ##servername you can use sqlcmd variables and pass them in for each environment which again a little cleaner than hardcoded server names.
The second approach is to moodify the dacpac to change the post delpoy script with your environment specific one, this is the my preferred and works best as part of a CI build, my process is:
Check-in changes
Build Server builds dacpac
Build takes dacpac, copies to the dev,qa,prod, etc env folders
Build replaces the post-deploy script in each with the env specific script
I call the scripts PostDeploy.dev.sql, PostDeploy.Qa.sql etc and set the Build action to "None" or they are added as "Script, Not in Build".
To replace the post-deploy script you just need to use the .net Packaging API or for some examples take a look at my Dir2Dac demo which does that and more:
https://github.com/GoEddie/Dir2Dac
more specifically:
https://github.com/GoEddie/Dir2Dac/blob/master/src/Dir2Dac/DacCreator.cs
var part = package.CreatePart(new Uri("/postdeploy.sql", UriKind.Relative), "text/plain");
using (var reader = new StreamReader(_postDeployScript))
{
reader.BaseStream.CopyTo(part.GetStream(FileMode.OpenOrCreate, FileAccess.ReadWrite));
}
I have solved this by writing a Powershell script that gets executed automatically when publishing, by an Exec Command in the Project-file.
It creates a script file, which includes all scripts found in a folder in the project (the folder is named like the target Environment).
This script is then included in the post-deploy script.

Is there a way to find test cases that are not part of any test suite?

The way that we use Microsoft Test Manager means that we want every test case to be included in at least one test suite. However, we have (manually) discovered some test cases that are not part of any test suite. Finding these by hand is very time consuming.
Therefore: Is there any way to find all test cases that are not part of any test suite?
(We're using Microsoft Test Manager 2012/2013.)
You can't do it using MTM (no matter which version you are using).
Using TFS 2012 the only way is to use TFS-API, here a short example how to check if a particular Test Case is a part of any Test Suite:
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
// Current user credentials will be used to access to TFS
TfsTeamProjectCollection tfsCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(<TFS Url>));
tfsCollection.EnsureAuthenticated();
ITestManagementService testManagementService = tfsCollection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = testManagementService.GetTeamProject(<team project name>);
// Get all Test Suites your Test Case belongs to
// (Across all Test Plans in the Team Project)
ITestSuiteCollection testSuites = teamProject.TestSuites.ReferencingTestCase(<test case id>);
bool doesItBelongToAnyTestSuite = testSuites.Any();
If you would use TFS 2013 it will be possible to achieve this using Work Item queries since Test Plan and Test Suite become Work Items with TFS 2013 Update 3 (RC was released on 2. July 2014).

How to get the test outcome programmatically?

I am using the Visual Studio agents to run VS coded UI tests on a remote test server (the test agent) from my own developer machine (the test controller).
When running tests locally, I was able to access and read the TRX results file that is created once the test had completed, but I am unable to access this file on the remote test server since the TRX results file remains within the Visual Studio folder on the test controller.
The reason I want to access the results file programmatically as I have code to read the file and then to send out the result as an automated email.
So, is there any way to get the outcome of the test programmatically so that I can send out the results email automatically?
Ideally, I would be able to get access to the TRX results file from the test server but I'm not sure if this is feasible or possible.
If you run the coded ui inside of a load test, you can set it to write to the LoadTest2010 database. From there you can set up ways to get the results and trigger events as with any database.

Resources