Ruby Cucumber Interview Questions and Answers

Q1 : Define Cucumber and mention its advantages.  
A : Cucumber is a software tool used to test other software and it functioned with the help of a very simple language programming, the Ruby programming language. The following are the advantages of the Cucumber tool –

  • Cucumber software tool allows the stakeholders of business to be involved in it even if they don’t know how to code.
  • The experience of the users is prioritized by using the Cucumber tool.
  • Cucumber tool allows the codes to be reused.

Q2 : What is the meaning of Steps in Cucumber tool? 
A : The steps are sequences which help in describing how exactly the test scenario will take place. It also defines the preconditions of the test scenario. It consists of the following commands or keywords-

1. Given – Before starting the tests, all of its conditions is described by this.
2. When – The actions during Cucumber tests are described by this.
3. Then – This is the outcome of the actions which took place When.

Some other keywords found here are –

1. And – logical representation of the Cucumber test
2. But – This is same as And but is negative form.

Q3 : What do you mean by the term Hooks used in Cucumber tool?  
A : Certain setups are performed before performing the actual Cucumber tests. Hooks allow the setups to work properly. Hooks are also known as executive Ruby blocks and are considered to be similar to the method of JUnit. They can also be placed under support and has global application. Mainly three types of hooks exist –

  • Before – Mainly runs before the commencement of a scenario.
  • After – Runs after the commencement of a scenario.
  • Around – Runs around the scenario and also controls it.

Certain other types of hooks are –

  • Before Step
  • After step

After configuration which runs after the configuration of the Cucumber test.

Q4 : Define Cucumber tags. Mention its purpose. 
A : In order to filter scenarios of tests, Cucumber tags are used. The scenarios are executed based on the tags which are provided by the scenarios. The scenarios can be added with the help of @ and the command – t @ .

Q5 : What are Cucumber options? What are its properties?  
A : Cucumber tests are executed under various properties and these are known as Cucumber options. The following are its properties –

1. Feature – This involves the path to the feature file
2. Glue – Similar way towards the step definition.
3. Dry run – This checks missing definition.
4. Tags – scenarios in the feature file are grouped with the help of this property.
5. Strict – This helps on making an execution stop if some of the steps are missing.
6. Monochrome – Output can be read using this feature.

Q6 : What is Cucumber Report? Mention the benefits of Cucumber Report.  
A : The HTML format generated by Cucumber software development tool is known as Cucumber Report. The following are the benefits of such a software development tool’s report –

  • Testing of other software can be easily done with the help of Cucumber tool.
  • The report is also used for easy execution of software testing.
  • The scenario is written in a very easy format.
  • The codes are also written in an easy format.
  • The Cucumber report also helps the Cucumber tool in prioritizing the experiences of the users.
  • It is so easy to use that those who are not technically knowledgeable can also use this tool.

Q7 : Mention the software which is required to run Cucumber tool in Java. 
A : The following are the software required to run to the Cucumber tool in Java –

1. Eclipse and Intelli J IDE
2. Gradle and Maven build tool
3. Cucumber
4. JUnit and TestNG testing framework
5. Selenium

Q8 : Differentiate between Jbehave and Cucumber.  
A : Cucumber tool and Jbehave have the same reason to be used by a user however they are built by the different framework –

1. Jbehave is based on Java whereas Cucumber is based on Ruby programming language.
2. Stories make the base of Jbehave whereas features make the base of Cucumber tool.

Q9 : What are the advantages of using Ruby on Rails?  
A : The following are the advantages of using Ruby on Rails –

1. Pure OOP Concept
2. Gems and Plugins
3. Scaffolding
4. DRY Principle
5. Convention over Configuration

Q10 : Define Behavior Driven Development (BDD).  
A : Behavior Driven Development is considered to be a type of software developmental processes. Mainly test-driven development (TDD) is the origin of the behavior is driven development. All the different principles of TDD is combined with the entire all the object-oriented design and analysis and in order for the software development project to work.

Q11 : Define regular expressions.  
A : A specific amount of test is expressed with the help of a pattern known as the regular expression. Mainly texts containing single characters are expressed with the help of this pattern.

Q12 : Define Cucumber Command-Line Interface.  
A : The command line interface of the Cucumber tool helps in covering the list of various information and provide a basic summary of the steps of the tests. It also provides certain commands.

Q13 :  Define Cucumber Dry Run?  
A : All the feature files and the step definitions are all compiled together with the help of Cucumber Dry Run. It also shows the errors which appeared during the compilation process. Cucumber features – dry-run is one such example.

Q14 : Define background available in the feature file.  
A : The background keyword found in the feature files are basic steps to be executed before every test scenario. The steps are written under this keyword in order to be executed and in this way, they will be executed at first before the commencement of any Cucumber test.

Q15 : Differentiate between Cucumber tool and Rspec.  
A : The main differences between Cucumber tool and Rspec are as follows –

Cucumber tool is used for testing of various software. It can also be used for integration and system tests. However, on the other hand, Rspec is used for the purpose of Unit Testing.

Q16 : What is the meaning of the term profile in the Cucumber tool? What are the commands used to execute one?  
A : For defining steps and defining certain specific features of Cucumber tests, Cucumber profiles are created.
Cucumber features –  p, these are the commands used to execute.

Q17 : What are the advantages of using Ruby on Rails?  
A : The following are the advantages of using Ruby on Rails –

1. Pure OOP Concept
2. Gems and Plugins
3. Scaffolding
4. DRY Principle
5. Convention over Configuration

Q18 : Define test harness.  
A : Test harness performed various functions of the Cucumber test. It has the main responsibility of setting up test context. It also helps in the browser interaction and files like step definition are cleaned with the help of test harness.

Q19 : Mention the files which are required for the execution of Cucumber test.  
A : Two main files which are required for a Cucumber test execution are Step definition and Features.

Q20 : How can any scenario in the feature file be written? 
A : The Cucumber test scenarios are written with the help of a very simple language in the feature file. This language is known as Gherkin. This simple programming language is also business readable. The behavior and how the software developmental process works are all described with the help of this language. It is specific to a particular domain of programming and all these are described from the perspective of a user. Hence, easy collaboration can be done by non-programmers too and can be easily read.

Q21 : Cucumber also works with the Browser Automation. How?  
A : Cucumber tool works with browsers like Selenium and WATIR-WebDriver. Build in browser automation is not available in the Cucumber tool. It also works with another type of browser like the Active record by supporting their tests.

Q22 : What are the various examples of behavior driven test written in plain text?  
A : The following are the examples –

1. Feature – XYZ page is needed to be visited in the abc.com.
2. Scenario – This is the final visit to the abc.com.
3. Given – Staying on the website, abc.com.
4. When – Clicking on the XYZ page while being on the website, abc.com.
5. Then – ABC page is to be seen here.

Q23 : In what ways does the Cucumber execution start? What are the variously advanced frameworks used with the Cucumber development tool?  
A : Support is the place from where the execution of Cucumber test starts. The software which requires testing is mainly prioritized by the Cucumber software development tool. For the execution of the process of testing, the file gets loaded at first in Support and it is generally the env.rb file. Then the hooks.rb file gets loaded. Finally, the steps of the scenarios get executed from the feature file. Cucumber testing tool executes its work with the help of all these folders, commands and keywords. Support is considered to be very important in this respect.

The following are the advancement frameworks available with the Cucumber tools –

1. Page Object Model
2. Object Repository
3. Extent Reporting
4. Dependency Injection
5. Log4j

Q24 : Is it compulsory to use keywords while performing Scenario steps? 
A : Scenario steps can be written without using keywords and hence it is absolutely not necessary to use key words.

Q25 : Define feature file. Mention the components of feature file.  
A : In order to perform a Cucumber test, a code is required and for the execution of such a code, certain conditions are required. Feature file consists of such conditions and parameters. The following are the components contained by the feature file –

1. Feature
2. Scenario Outline
3. Scenario
4. Given
5. When
6. Then