简体   繁体   中英

Is it possible to run specflow tests programmatically?

In my project we had BDD tests which I have written using specflow, nUnit and Watin. I run these tests from visual studio using resharper. Now I want to expose these features and scenarios to non technical people and I want them to run these tests.

Something like I want to list all the tests in a browser and user should be able to run those tests by clicking on them. Can this be achieved ? Is there any addin ?

Currently we use Team Foundation Server as our build server.

TeamCity , a Continuous integration server by JetBrains provides this as a webbased functionality. It even provides statistics and test output results.

It supports nUnit out of the box. SpecFlow and Watin are supported with some configuration.

在此输入图像描述

You can use the Pickles project to produce stakeholder-friendly documentation (including HTML) from the Gherkin specifications in your source control.

There's no facility for running the tests from the HTML. It's open-source so perhaps you can extend it this way... however, I personally don't see the value in having non-technical users actually execute the specifications. I would have your continuous integration server run the SpecFlow tests and generate a step definition report periodically. The non-technical users can then browse to these reports to see current project status.

To give access to your feature files to non technical people you can use http://www.speclog.net/

Spec log will allow non tech to edit and create new features and will automatically synchronise them with TFS.

Unfortunately it's not free and you can't run the specs from that tool.

The BIGGEST problem you are going to have is that the plain text feature file, automatically gets converted to a xxx.feature.cs file by the SpecFlow Visual Studio plugin. So your process is this,

  • Modify xxxx.feature file
  • Find some way to get the SpecFlow plugin to generate xxx.feature.cs
  • Compile
  • Run tests by using NUnit/Xunit (as configured)
  • Gather and present test success report

To me this is a process has a name, I'd called it development.

BDD however is a different process, it's all about collaboration and communication with the business in order to devise a specification. In the beginning there were no tools, but the process still worked.

A number of my co-workers have been using BDD techniques on a variety of real-world projects and have found the techniques very successful. The JBehave story runner – the part that verifies acceptance criteria – is under active development.

Dan North - Introducing BDD 2006

Don't get caught up on the tools alone or you'll miss the vital part of the process. You'll get so much benefit by working with your BA to define the new specification together collaboratively.

PS Another way to consider this is that the specification and code should always be in step. Just by defining a new example, we don't magically move the code forwards to meet that example. Instead the most common practice is to develop the code to meet the new example, and then check in the new specification and code as a single change set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM