{"id":13562,"date":"2017-03-23T00:00:00","date_gmt":"2017-03-23T05:00:00","guid":{"rendered":"https:\/\/centricconsulting.com\/post\/running-cucumber-using-rake_sqat-columbus\/"},"modified":"2022-03-06T18:57:58","modified_gmt":"2022-03-06T23:57:58","slug":"running-cucumber-using-rake_sqat-columbus","status":"publish","type":"post","link":"https:\/\/centricconsulting.com\/blog\/running-cucumber-using-rake_sqat-columbus\/","title":{"rendered":"Running Cucumber Using Rake"},"content":{"rendered":"

Learn how to run Cucumber on Rake to lead your agile testing team\u00a0down the path to\u00a0automation.<\/h2>\n

Blog seven\u00a0of a series<\/a>.<\/em><\/p>\n

Created by Jim Weinrich quite a few years ago, Rake is \u201ca Make-like program implemented in Ruby.\u201d<\/p>\n

For those of you unfamiliar with JAVA, \u201cMake in Java<\/b>\u00a0(jmk) is an application that\u00a0is used to ensure a set of files is in a consistent state. If jmk detects an inconsistency, it executes commands that correct the inconsistency.\u201d<\/p>\n

We still haven’t even\u00a0highlighted the\u00a0best part of the Rake file. Rake does in Ruby what Make does in JAVA: It ensures files are in a consistent state. Then it executes the task you specify.<\/p>\n

This is a huge benefit<\/em> because it ensures you don’t make any formatting mistakes in\u00a0Feature files, or insert typographical errors in a step definition.<\/p>\n

If there are inconsistencies, you’ll catch them by running Cucumber using Rake.<\/p>\n

Cucumber took advantage of the power of Rake to help you\u00a0create cucumber rake tasks. Setting these up is simple. In the Rake file, you need to require \u2018cucumber<\/strong>\u2019 and \u2018cucumber\/rake\/task<\/strong>\u2019.<\/p>\n

See the\u00a0results in the following cucumber rake task:<\/p>\n

\"Ruby\"<\/p>\n

Below is the\u00a0format of the cucumber rake task:<\/p>\n

\"Ruby\"<\/p>\n


\n<\/b>First, Cucumber takes advantage of Rakes\u2019 Task.new<\/strong>. This is where you create a new Rake task to execute. You can extend\u00a0this to create a new Rake task specific to Cucumber. The :task<\/strong> name<\/strong> can be any unique name you wish to name the task. More on this in a minute.<\/p>\n

Lastly, the Cucumber profile will determine which profile in the cucumber.yml file this specific task will use. The cucumber.yml file extends the command line for you. The format is simple: cucumber_profile: parameters<\/strong><\/p>\n

The cucumber profile then ties to\u00a0the cucumber rake task. Parameters can control anything from the format cucumber will use to where the output is sent to. An example of the default profile: –no-source –color –format pretty<\/strong><\/p>\n

Running with Rake<\/h2>\n

Rake is executed from the command line. The format is simple:\u00a0rake <task name><\/b><\/p>\n

The task name is specified in Cucumber::Rake::Task.new(:task name)<\/strong>. After you hit enter, Cucumber will go through every Cucumber Rake task looking for the specific task name you passed. Once found, it will execute.<\/p>\n

A\u00a0WebDriver Example<\/h2>\n

In future blog articles, we will build a WATiR-WebDriver-based Cucumber automation framework. In the blog about tags, we will set-up our Feature file with tags so it can be easily executed by Rake:<\/p>\n

\"Ruby\"<\/a><\/p>\n

For rake to execute this, we first need to set-up the cucumber.yml file like this:<\/p>\n

\"Ruby\"<\/a><\/p>\n

Next, set-up the Cucumber Rake Task:<\/p>\n

\"Ruby\"<\/p>\n

All that is left now is to open a command prompt and type:\u00a0rake webdriver_search<\/strong>. Cucumber should launch and you should see an all pass. To run this via RubyMine go to Tools -> Run Rake Task:<\/strong><\/p>\n

\"Ruby\"<\/p>\n

You will be presented with a list of all the Rake tasks you currently have. Note: you might have to reload rake tasks lists<\/strong>:<\/p>\n

\"Ruby\"<\/p>\n

Select webdriver_search<\/strong> and watch it run.<\/p>\n

Rake can be an extremely powerful tool. Mastering its nuances will enable you to control your output, manage reports much cleaner, and run your jobs in a Continuous Integration (CI) environment.<\/p>\n

In our next installment of this series,\u00a0we’ll explain how to drive a browser using WATiR WebDriver.<\/em><\/h3>\n","protected":false},"excerpt":{"rendered":"

Rake does in Ruby what Make does in JAVA: It ensures files are consistent, then executes. Run Cucumber using Rake to catch inconsistencies.<\/p>\n","protected":false},"author":63,"featured_media":17685,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_oasis_is_in_workflow":0,"_oasis_original":0,"_oasis_task_priority":"","_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[1],"tags":[],"coauthors":[15012],"acf":[],"publishpress_future_action":{"enabled":false,"date":"2024-07-21 22:41:56","action":"change-status","newStatus":"draft","terms":[],"taxonomy":"category"},"_links":{"self":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13562"}],"collection":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/comments?post=13562"}],"version-history":[{"count":0,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/posts\/13562\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media\/17685"}],"wp:attachment":[{"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/media?parent=13562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/categories?post=13562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/tags?post=13562"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/centricconsulting.com\/wp-json\/wp\/v2\/coauthors?post=13562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}