How can I filter the specflow features when running the test scripts in TFS Continuous Integration

1,572 views
Skip to first unread message

Kishore Babu

unread,
May 10, 2016, 2:31:35 AM5/10/16
to SpecFlow
Hi,

In my project, I have used SpecFlow to write the feature files and added my custom tags (Ex: @RunFeature1, RunFeature2). Also, I have used NUnit as Unit Test Provider for running my Tests.
As per my project demand, I configured to run the tests on nightly basis using TFS Continuous Integration Process. Everything is looking fine for me.
But, I have 350 Test Cases, I want to run only 100 specified Test Cases on Nightly build.
How Could I make this happen? Can I use Test Case Filter option in Build Definition Template? Or Do I have any other option?

Help is much appreciated.

Thank You,
Kishore G

Gáspár Nagy

unread,
May 10, 2016, 3:09:24 AM5/10/16
to SpecFlow
Hi,

This mainly depends on how you run the tests (that are technially nunit tests) on TFS. SpecFlow converts the scenario and feature tags into NUnit categories, so you need to figure out how you can filter for category with your runner. If you use the NUnit Test Adapter for Visual Studio, this might help: http://www.codit.eu/blog/2015/03/18/continuous-integration-with-javascript-nunit-on-tfsbuild-part-3-of-3-/

Br,
Gaspar

--

Gaspar Nagy Spec Solutions
coach, trainer and bdd addict
email twitter linkedin blog

specflow courses in london oslo in-your-office

 

Kishore Babu

unread,
May 10, 2016, 6:46:24 AM5/10/16
to SpecFlow
Hi Gaspar,

For TestCase Filter parameter in TFS Build Definition Template, I have provided like this, "CategoryAttribute = RunFeature1". But this does not worked for me and gave me the following error.

Exception Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.TestPlatformFormatException, Exception thrown executing tests

Thank You,
Kishore G
Capture.PNG

Sam Holder

unread,
May 10, 2016, 7:45:03 AM5/10/16
to specflow
This is not really a specflow issue, you just need to configure your test runner to run only tests in a certain category. This may help: https://blogs.msdn.microsoft.com/visualstudioalm/2012/09/26/running-selective-unit-tests-in-vs-2012-using-testcasefilter/ but if not then you'll have to bit of googling around that

--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kishore Babu

unread,
May 12, 2016, 12:46:00 AM5/12/16
to SpecFlow
Hi Sam,

Thank You for reply. :)

I am using the NUNit as my Unit Test Framework, but here in Build Definition Template the Test Case Filter attribute is accepting the MSTest Attribute. 

So, How can I filter my test cases? Your help is much appreciated.

I googled and every where most of them are using MSTest Arrtibutes.

Thank You,
Kishore G

Gáspár Nagy

unread,
May 12, 2016, 2:44:57 AM5/12/16
to SpecFlow
Hi,

The test adapter that enables the execution of different unit test frameworks on TFS (and in Visual Studio Test Explorer), should accept the TestCategory filter option and translate it to the categorization feature of the test runner itself. So TestCategory=bla should also work with NUnit.

I posted an article in this topic: http://gasparnagy.com/2016/05/specflow-tips-run-only-specific-scenarios-in-tfsvsts-build/

Br,
Gaspar

Kishore Babu

unread,
May 19, 2016, 3:37:26 AM5/19/16
to SpecFlow
Hi Gaspar,

Thank You for the reply. I will try this. Also, how the VS Test Runner will leverage the features of the NUnit. ?

Thank You,
Kishore G

Kishore Babu

unread,
May 25, 2016, 3:27:31 AM5/25/16
to SpecFlow
Hi Gaspar,

Thank You very much, this solution worked for me. Now I am able to run specific test cases based on the tag even I am using NUnit.

Thank You,
Kishore G

On Thursday, May 12, 2016 at 12:14:57 PM UTC+5:30, Gáspár Nagy wrote:
Reply all
Reply to author
Forward
0 new messages