{"id":78520,"date":"2020-04-20T01:42:38","date_gmt":"2020-04-19T23:42:38","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs"},"modified":"2020-04-20T01:42:38","modified_gmt":"2020-04-19T23:42:38","slug":"udobnyj-bdd-specflow-tfs","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs","title":{"rendered":"Convenient BDD: SpecFlow+TFS","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>There are many articles on how to use SpecFlow and how to configure TFS to run tests, but there isn't one that covers all aspects. In this article, I will explain how to make the execution and editing of SpecFlow scenarios convenient for everyone. <\/p>\n<p><\/p>\n<h3 id=\"pod-katom-vy-uznaete-kak-poluchit\">Below, you will learn how to obtain:<\/h3>\n<p><\/p>\n<ul>\n<li>Running tests from TFS<\/li>\n<li>Automatically linking scenarios to test cases in TFS<\/li>\n<li>Always up-to-date content of test cases in TFS<\/li>\n<li>The ability to edit scenarios directly in the version control system by testers<br \/>\n<img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/3f9aa21842200ef09cb1dfb28b5194d2.jpg\" style=\"display:block;margin: 0 auto;\" \/><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/li>\n<\/ul>\n<p><\/p>\n<h3 id=\"predystoriya\">Background<\/h3>\n<p><\/p>\n<p>We faced the task of automating the testing of an application using the BDD approach. Since TFS is the main task tracking system in our company, I envisioned a picture where the steps of the SpecFlow scenario are the steps of the test cases in TFS, and tests are executed from the test plans. Next, I will explain how I implemented this.<\/p>\n<p><\/p>\n<h3 id=\"chto-nam-potrebuetsya\">What we will need:<\/h3>\n<p><\/p>\n<ol>\n<li>A project with tests on SpecFlow<\/li>\n<li>Azure DevOps Server (aka Team Foundation Server)<\/li>\n<li>A tool for synchronizing SpecFlow scenarios with test cases in TFS<\/li>\n<\/ol>\n<p><\/p>\n<h2 id=\"nastroyka\">Settings<\/h2>\n<p><\/p>\n<h3 id=\"1-sozdanie-sborki-proekta-s-testami\">1. Creating a build for the project with tests<\/h3>\n<p><\/p>\n<p>This is straightforward: building and publishing artifacts. More about the third task later.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/84d4f0189ca000d3fda19f570ee69e49.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h3 id=\"2-sozdanie-reliza-dlya-zapuska-testov\">2. Creating a release to run tests<\/h3>\n<p><\/p>\n<p>We create a release with one task \u2014 Visual Studio Test<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/c41b05bdd43c6620cd24e956715aa9cd.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In this case, the task is configured to run tests manually from the test plan. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/75f113c9cf9aee8eabf4d8b30ba1b20c.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h3 id=\"3-sinhronizaciya-testkeysov\">3. Synchronizing test cases<\/h3>\n<p><\/p>\n<p>We know that Visual Studio allows linking test methods to test cases in TFS and running them from test plans. To avoid doing this manually and to synchronize the content of scenarios, I wrote a simple console application <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/kharakhorin\/FeatureSync\">FeatureSync<\/a><\/noindex>. The principle is simple \u2014 we parse the feature file, and using the TFS API, we update the test cases.<\/p>\n<p><\/p>\n<p><strong>How to use FeatureSync<\/strong><\/p>\n<p><\/p>\n<p><strong>Add a namespace and locale to the header of the feature file:<\/strong><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">#language:en\n@Namespace:Application.Autotests\nFeature: Log to application<\/code><\/pre>\n<p><\/p>\n<p>*the namespace must match the name of the .dll file in which the test methods are contained<\/p>\n<p><\/p>\n<p><strong>Create empty test cases in TFS and add tags with their IDs to the scenarios:<\/strong><\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/c8627b5d822976a7871c21614bbce523.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">@2124573 @positive\nScenario: Successful authorization\n    Given I am on the authorization page\n    And I enter:\n        | Login | Password |\n        | user  | pass     |\n    When I press the Login button\n    Then the Browser redirects to the Home page<\/code><\/pre>\n<p><\/p>\n<p><strong>Run FeatureSync:<\/strong><\/p>\n<p><\/p>\n<pre><code class=\"plaintext\">FeatureSync.exe -f C:FolderWithFeatures -s https:\/\/tfs.server.com\/collection -t 6ppjfdysk-your-tfs-token-2d7sjwfbj7rzba<\/code><\/pre>\n<p><\/p>\n<p>In our case, the execution occurs after the build of the project with tests:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/633029616249a0a0a54f1315a9552d78.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><strong>Result of synchronization<\/strong><\/p>\n<p><\/p>\n<p>The steps of the SpecFlow scenario have been synchronized, and the status Automation has been set.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/f3713d8f66e72aeac04c15aefa3ae885.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/ef366421887e1b29d384baad46ff8196.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h3 id=\"4-nastroyka-test-plana\">4. Configuring the test plan<\/h3>\n<p><\/p>\n<p>We create a test plan, add our automated cases to it, and select the build and release in the settings.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/e5dc499dfd4340c0fa30926a301a1297.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/a871cfdbb52d0d94d1842987859e2380.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h3 id=\"5-zapusk-testov\">5. Running Tests<\/h3>\n<p><\/p>\n<p>Select the necessary test in the test plan and launch it.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"Convenient BDD: SpecFlow+TFS\" src=\"\/wp-content\/uploads\/2020\/04\/9e6e72ede126ddb582f3541c7d001308.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<h3 id=\"zaklyuchenie\">Conclusion<\/h3>\n<p><\/p>\n<p>Advantages of this configuration: <\/p>\n<p><\/p>\n<ul>\n<li>any tester can open the feature file in the web version control system, edit it, and the changes will take effect immediately after the build.<\/li>\n<li>tests can be run individually at any time.<\/li>\n<li>transparent test model \u2014 we always know what the test we launched is doing.<\/li>\n<\/ul>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/497730\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SpecFlow, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TFS \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0431\u044b \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 SpecFlow \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0445. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c: \u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0437 TFS \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043b\u0438\u043d\u043a \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":78521,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-78520","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SpecFlow, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TFS \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0431\u044b \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0423\u0434\u043e\u0431\u043d\u044b\u0439 BDD: SpecFlow+TFS | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SpecFlow, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TFS \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0431\u044b \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-04-19T23:42:38+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-04-19T23:42:38+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Convenient BDD: SpecFlow+TFS | ProHoster","description":"There are many articles online about how to use SpecFlow and how to configure TFS to run tests, but none that cover all aspects.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0423\u0434\u043e\u0431\u043d\u044b\u0439 BDD: SpecFlow+TFS | ProHoster","og:description":"\u0412 \u0441\u0435\u0442\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SpecFlow, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c TFS \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u0430 \u0431\u044b \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/udobnyj-bdd-specflow-tfs","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-04-19T23:42:38+00:00","article:modified_time":"2020-04-19T23:42:38+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"78520","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 16:56:36","updated":"2022-09-30 18:25:41","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/78520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=78520"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/78520\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/78521"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=78520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=78520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=78520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}