Is there a way to associate Specflow+Runner test cases with Azure Test plan? - specflow

We are looking for some solutions around associating our automation test cases with Azure test plan with Specflow+Runner.
Tech stack:
Visual Studio 2017/19
.Net Framework 4.8
Specflow 3.1.97
SpecRun.Runner/SpecRun.Specflow 3.2.31
We have recently started using Specflow+ Runner and previously we were using Specflow with Xunit. When I am trying to associate a test case in Visual Studio, we are facing below issue. This used to work perfectly when we were using Xunit.
If you have come across this situation and have got a solution or workaround, please do share with us. Basically we are looking at something that can tag our automation test cases in test plan.
Below is the link that provides information about associating test cases, which worked fine for us till we were using XUnit.
https://learn.microsoft.com/en-us/azure/devops/test/associate-automated-test-with-test-case?view=azure-devops
Please do let me know in case you need any further information on this from my side. Any help will be greatly appreciated.

Sadly the association with test cases when using the SpecFlow+ Runner is not possible out of the box. There is no possibility to extend this behavior we are aware of.
But you could use SpecSync. It synchronizes your Scenarios into Test Cases and also provides the test execution results.

You can use the Azure test API's and add them in the Hooks with the correct order so test runs can be created, test results can be updated during test runs. You just need to understand how Azure test API's work and add the test case ID's to your scenario names.

Related

Which tests should be run since a previous TFS build?

My managers want we to determine which tests might have to be run, based on coding changes that were made to the application we are testing.
But, it is hard to know which tests are actually needed to be re-verified as a result of a code change. What we have done is common to test the entire area where the code change occurred / or the entire proj, solution.
We were told this could be achieved by TFS build or MTM tools. Could someone share the details?
PM:We are running on TFS 2015 update4,VS2017.
There is a concept of Test Impact Analysis which helps in analysis of impact of development on existing tests. Using TIA, developers know exactly which tests need to be verified as a result of their code change.
The Test Impact Analysis (TIA) feature specifically enables this – TIA
is all about incremental validation by automatic test selection. For a
given code commit entering the pipeline TIA will select and run only
the relevant tests required to validate that commit. Thus, that test
run is going to complete faster, if there is a failure you will get to
know about it faster, and because it is all scoped by relevance,
analysis will be faster as well.
Test Impact Analysis for managed automated tests is available via a checkbox in the 2.* preview version of the VSTest task.
If enabled, only the relevant set of managed automated tests that need to be run to validate a given code change will run. Test Impact Analysis requires the latest version of Visual Studio, and is presently supported in CI for managed automated tests.
However this is only available with TFS2017 update1(need 2.* preview version of VSTS task). More details please refer this blog: Accelerated Continuous Testing with Test Impact Analysis

Generating test cases in TFS(MTM) using Specflow feature file

I'm very new to Specflow and working on evaluating it. I was able to write scenario, step definition, and execute the test. But now I'm stuck on integrating the feature file to TFS.
I want to know if there is a way to integrate Specflow feature file to TFS(MTM)
Following is the workflow I want to accomplish :
A feature file is created with multiple scenario
If the feature file is checked in, scenarios are automatically generated in TFS with corresponding area (maybe using tags?)
or I would appreciate if you could share any other integration suggestions you may have.
Thank you in advance!
for export scenario can be used TFS API
example - Create work item in Team Project (TFS) using c# code
https://social.msdn.microsoft.com/Forums/vstudio/en-US/1ff5415e-0ef2-4c65-b0b7-a109187adf51/create-work-item-in-team-project-tfs-using-c-code?forum=tfsgeneral

Proactive export testcases from MTM

Today faced a challenge, due to some infrastructure issue our TFS and MTM was down and the whole testing team was sitting idle as they can't access their test scripts. Is there a way that we can export/download test scripts from MTM to local machine (as we do for codebase i.e. local machine copy) so as to avoid this type of problem.
I know this will be a common problem but somehow unable to find a answer to this.
You can export an entire test plan from the web interface and you have the possibility to choose if the test cases with steps are included or not in the export.
You cant export for offline access. You can create static report of all of the test cases and steps in the web access. There is however no easy to get the data back in.
To be honest this is not a common ask as most folks TFS servers do not randomly go offline. As TFS is a production system you should get at least four nines SLA. If you don't then I would recommend that you move your TFS to VSO.

Automated application testing with TFS

I think I'm missing a link somewhere in how microsoft expect TFS and automated testing to work together. TFS allows us to create test cases that have test steps. These can be merged into a variety of test plans. I have this all setup and working as I would expect for manual testing.
I've now moved into automating some of these tests. I have created a new visual studio project, which relates to my test plan. I have created a test class that relates to the test case and planned to create a test method for each test step within the test class, using the ordertest to ensure that the methids are executed in the same order as the test steps.
I'd hoped that I could then link this automation up to the test case so that it could be executed as part of the test plan.
This is when it all goes wrong, It is my understanding that the association panel appears to only hook a test case up to a particular test method, not a test step?
Is my understanding correct?
Have MS missed a trick here and made things a litte too complicated or have I missed something? If I hook things upto a whole test case to a method I lose granulaity of what each is doing.
If each test step was hooked into a test method it would be possible for the assert of the test method to register a pass or fail of the overall test case.
Any help or direction so that I can improve my understanding would be appreciated.
The link is not obvious. In Visual Studio Team Explorer create and run a query to find the test case(s). Open the relevant test case and view the test automation section. On the right hand side of the test automation line there should be an ellipsis, click it and link to the test case.
I view this as pushing an automated test from Visual Studio. Confusingly you cannot pull an automated test into MTM.
You can link only one method to a test case. That one method should cover all the steps written in its associated test case including verification(assertions).
If it is getting impossible to cover all steps in one test method or if your have too many verifications is your test case, then the test case needs to be broken down to smaller test cases and each of the test cases will have one automated method associate with it.
Automation test should work like this. (Not a hard rule though..)
Start -> Do some action -> Verify (Assert) -> Finish
You can write as many assertions as possible, but if first assert fails then test won't proceed further to do other assertions. This is how manual testing also works, ie Test fails even if 1 step out of 100 fails.
For the sake of automation test maintainability it is advisable to add minimum asserts in automation test and easiest way to achieve this is by splitting the test case. Microsoft or other test automation provider works this way only and we don't write test methods for each and every steps. This would make things very complicated.
But yes, you can write reusable methods(not test methods) in your test framework for each steps and call them in your test methods. For example you don't have to write code for a test case step say "Application Login" again and again. You can write your method separately and call that in your test method which is linked to the test case.

Run test plan against 3rd party versioned programs

Using Visual Studio Online I created a test plan for a program that was written by a different company that my company uses. We have a specific set of tests that need to be tested before we accept a new version of this program. So when I edit the test plan I would like to be able to manually select a build by typing in say version "1.0.1.195". Then when a newer version comes out I can just type in a newer version and retest using those same tests. However when I go to select a build TFS is filtering against my builds for my code. Is it possible to do what I'm asking using TFS?
EDIT
To answer a few of the questions in the comments I'll be a bit more descriptive of what I am doing. A 3rd party company made a program we use to test some hardware. Every now and then there is an update to that software. Since a few of us use this program to test out the hardware we need to know that the software can be installed with little to no down time while upgrading. So we came up with a small set of tests that we run the program through to make sure that we can test reliably. Those tests were written in a Word document, so I put them into MTM. Although I make some software that is related to this their software depends on mine. I've not had to update my code for some time now. My overall intention is to use MTM to document my testing of this program.
Do you want to store the version of the 3rd party component along with the test result of the test run it was tested with on TFS?
That would be nice. My ultimate end game is to put the results of said test back into that Word Document and make that available to those who don't have MTM installed (which is everyone). This way when a new version of the software is updated I can just go into MTM reset all my tests back to active update the version number and retest.
The build you set up in Microsoft Test Manager (MTM) defines where is the drop location containing your tests, not the application under test (it can be different if you build your tests using another build).
That's why you only can select one of your builds for your code.
What you are talking about is deployment.
That means you have to make sure the right version of the 3rd party program is deployed to the environment the tests are running on.
EDIT
What you need is a Test Configuration
Here you can find a is a good explanation how to create one: Test Configurations - specifying test platforms
The idea in your use case would be as following
(below I'm using terms described in the article mentioned above):
Create a Configuration Variable where you will store the current version of the 3rd party program
Create a Test Configuration and add this variable to it.
Set this Test Configuration as default test configuration for your test plan.
Be aware, if your test plan already contains test cases you will have to add this Test Configuration to each Test Case manually since only new added Test Cases get it assigned automatically
If you get a new version of the 3rd party program you will:
Add the new version of the program to the values allowed for the Configuration Variable
Open the Test Configuration you are using and update the program's version to the new one.
Reset your tests and run them.
Doing so you:
store all versions you have tested so far in the Configuration Variable since you add the new one instead of overwrite the old one, so you get a kind of history.
store the last version you have tested in the Test Configuration.
That should meet you needs.
Additional suggestion
(has nothing to do with your question but with your use case)
Consider describing tests within your Test Cases instead of creating a Word document.
Here is a good place to start reading: How to: Create a Manual Test Case
The benefits would be:
You can run your manual tests using Test Runner provided by MTM
Doing so you will have all steps you have done stored by the Test Result, you can add comments to each step when executing that, etc.
You can still export the test description to a Word document using this MTM add-on: Test Scribe.
Using this add-on you can also create a report of your test execution.
Additionally, if you are going to use MTM more in your daily job I would recommend you this free e-book Testing for Continuous Delivery with Visual Studio 2012

Resources