How to set up execution order on Specflow Feature file

6,569 views
Skip to first unread message

Shakthi Ramalingam

unread,
Apr 7, 2016, 2:22:22 PM4/7/16
to SpecFlow

Could you please suggest how to orchestrate features - what I meant here is basically I'm expecting how to setup execution order at feature level.


Say for example:


Feature Customer - Execution Order = 1

Feature Order - Execution Order = 2 

Feature Supplier - Execution Order = 3


Thanks,


R.Shakthi

Sam Holder

unread,
Apr 8, 2016, 3:55:47 AM4/8/16
to specflow
The short answer is that you can't. Test order is determined by the test runner, not by specflow.

The long answer is this is a bad idea. The better approach is to make your tests independent. If you need a customer to be created before you can create an order then had a step in the order feature which ensures that the customer is created. somethign like:

Given I have a customer 'bob'
When 'bob' orders a 'foo'
Then ....

--
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.

András Csányi

unread,
Apr 8, 2016, 10:36:18 AM4/8/16
to spec...@googlegroups.com
I agree with Sam. At first seems good idea having tests built on each other, but it becomes to a nightmare very fast. You can use the Background part of the feature file to describe general preconditions for the scenarios. I use them to create the dataset needed for the entry criteria.

- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu -- http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

Feuerfuss Fifimus

unread,
Jun 9, 2016, 9:31:24 AM6/9/16
to SpecFlow
You can't do this with VS. But when we created some very long running tests for our complex applications, we got the order to make some modules out of it.
I implemented a player for the projects and it's currently growing into some kind of basic test management tool for specflow tests.
First have a look at this old batch file:

set__COMPAT_LAYER=RunAsInvoker

@echo off
C
:\NUnit\bin\nunit-console-x86.exe /labels /out=TestResult.txt /xml=TestResult.xml "C:\Path\to\VS\generated.dll"

"C:\xxx\packages\SpecFlow.1.9.0\tools\specflow.exe" nunitexecutionreport "C:\xxx\someproject.csproj" /out:"C:\xxx\Desktop\TestResult.html"

if NOT %errorlevel% == 0 (
echo
"Error generating report - %errorlevel%"
GOTO
:exit
)
if %errorlevel% == 0 C:\xxx\Desktop\TestResult.html"

:exit

This makes you able to run a test outside of the VS. You might then start the batches one after another or program something to start the test in some kind of order.
If this is a good idea for you or not, i don't know.
Reply all
Reply to author
Forward
0 new messages