JBehave Interview Questions And Answers

JBehave Interview Questions And Answers. Here Coding compiler sharing a list of 30 Real-Time JBehave Interview Questions For Experienced. These JBehave questions were asked in various interviews conducted by top MNC companies. JBehave BDD testing interview questions are prepared by industry expert JBehave experts. We hope that this list will help you to crack your next JBehave job interview. All the best for future and happy JBehave learning.

JBehave Interview Questions

  1. What is JBehave Tool?
  2. What do you understand by Behavior-driven development?
  3. What is a BDD tool? What are BDD tools used for?
  4. What are the features of JBehave?
  5. What are the different JBehave modules?
  6. Explain how POM artifact can be declared as a dependency using Apache Maven?
  7. Explain how POM artifact can be declared as a dependency using Apache Ant?
  8. Which testing frameworks does JBehave support?
  9. How do you make your scenarios fail when steps are not matched and are shown as pending?
  10. How do you output my story steps just when a story fails?
  11. Can I insert comments in the textual scenarios?
  12. BDD focuses mostly on what?
  13. What are the principles of BDD?
  14. What are Stories, Scenarios, and Steps in BDD?
  15. Can you explain Stories, Scenarios, and Steps in BDD with an example?

JBehave Interview Questions And Answers

JBehave Interview Questions
JBehave is an Open source software
JBehave is a Framework for Behaviour-Driven Development (BDD).
JBehave provides BDD, an evolution of Test-Driven Development (TDD) and Acceptance-Test Driven Developement (ATDD).
JBehave BDD Aims to make development practices more accessible and intuitive to newcomers and experts alike.
JBehave Licence Released under a BSD-style license
JBehave written in Java-based framework

1) What is JBehave Tool?

A) JBehave is a Java-based framework supporting Behaviour-Driven Development (BDD), an evolution of Test-Driven Development (TDD) and Acceptance-Test Driven Development (ATDD).

2) What do you understand by Behavior-driven development?

A) In software engineering, behavior-driven development (BDD) is a software development process that emerged from test-driven development (TDD). The behavior-driven development combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software development and management teams with shared tools and a shared process to collaborate on software development.

3) What is a BDD tool? What are BDD tools used for?

A) BDD is principally an idea about how software development should be managed by both business interests and technical insight, the practice of BDD does assume the use of specialized software tools to support the development process. Although these tools are often developed specifically for use in BDD projects, they can be seen as specialized forms of the tooling that supports test-driven development.

4) What are the features of JBehave?

A) JBehave is a framework for Behaviour-Driven Development (BDD).

Features of JBehave include:

  • Pure Java implementation, which plays well with Java-based enterprises or when interfacing to any environment that exposes a Java API.
  • Users can specify and run text-based user stories, which allows “out-in” development.
  • User stories can be written in JBehave syntax or Gherkin syntax.
  • User stories can be specified as classpath resources or external URL-based resources.
  • User stories can be executed concurrently, specifying the number of concurrent threads.
  • User stories can be documented via generic user-defined meta information that allows easy story filtering and organization into story maps.
  • Annotation-based binding of textual steps to Java methods, with auto-conversion of string arguments to any parameter type (including generic types) via custom parameter converters.
  • Annotation-based configuration and Steps class specifications
  • Dependency Injection support allowing both configuration and Steps instances composed via your favorite container (Guice, Needle, PicoContainer, Spring, Weld).
  • Groovy scripting supported for writing configuration and Steps instances
  • Extensible story reporting: outputs stories executed in different human-readable file-based formats (HTML, TXT, XML). Fully style-able view.
  • Story cross-reference report format in JSON and XML, consumable by external applications.
  • Auto-generation of pending steps so the build is not broken by a missing step, but has the option to configure breaking build for pending steps.
  • Pluggable step prioritizing strategy. Strategies bundled in core include: by priority field and by Levenshtein Distance.
  • Localisation of user stories, allowing them to be written in any language.
  • IDE integration: stories can be run as JUnit tests or other annotation-based unit test frameworks, providing easy integration with your favorite IDE.
  • Ant integration: allows stories to be run via Ant task
  • Maven integration: allows stories to be run via Maven plugin at given build phase

5) What are the different JBehave modules?

A) JBehave provides the following modules, defined as POM artifacts:

Modules in JBehave:

  • jbehave-core
  • jbehave-groovy
  • jbehave-scala
  • jbehave-guice
  • jbehave-needle
  • jbehave-pico
  • jbehave-spring
  • jbehave-weld
  • jbehave-odf
  • jbehave-google
  • jbehave-rest
  • jbehave-ant
  • jbehave-hudson-plugin
  • jbehave-jenkins-plugin
  • jbehave-maven-plugin
  • jbehave-distribution

Once a version has been chosen, each artifact will declare the dependencies required.

6) Explain how POM artifact can be declared as a dependency using Apache Maven?

A) Using Apache Maven, the dependencies are declared in the Maven pom.xml:

<dependency>
<groupId>[groupId]</groupId>
<artifactId>[artifactId]</artifactId>
<version>[version]</version>
</dependency>

and the use of a custom settings.xml is declared via command line:

mvn -s settings.xml <goals>

7) Explain how POM artifact can be declared as a dependency using Apache Ant?

Using no dependency management tool, the build.xml in the lib directory of the binary distribution provides a target to copy to the lib directory all dependencies declared in the Maven pom.xm:

ant copy-dependencies

Using Maven Ant Tasks, the Ant dependency fileset can be created, with the Maven settings.xml provided specifying the remote repositories:

<project name=”my_project” default=”build” xmlns:artifact=”antlib:org.apache.maven.artifact.ant”>

<artifact:pom id=”pom” file=”pom.xml” settingsFile=”settings.xml” />
<artifact:dependencies filesetId=”dependency.fileset” pomRefId=”pom” useScope=”test” />
<dependency groupId=”org.jbehave” artifactId=”jbehave-ant” version=”[version]”/>
<dependency groupId=”org.jbehave” artifactId=”jbehave-core” version=”[version]” classifier=”resources” type=”zip”/>
<dependency groupId=”org.jbehave.site” artifactId=”jbehave-site-resources” version=”3.1.1″ type=”zip”/>

</artifact:dependencies>

</project>

8) Which testing frameworks does JBehave support?

A) JBehave comes bundled with out-the-box JUnit support but has no tie-in to JUnit. You can easily configure stories to run with another testing framework, such as TestNG or Spring’s Test module.

9) How do you make your scenarios fail when steps are not matched and are shown as pending?

A) Configure the PendingStepStrategy: in Configuration

new MostUsefulConfiguration().usePendingStepStrategy(new FailingUponPendingStep());

10) How do you output my story steps just when a story fails?

A) Configure the StoryReporter in Configuration

new MostUsefulConfiguration().useStoryReporter(new SilentSuccessFilter(ConsoleOutput()));

Alternatively, you can use PropertyBasedConfiguration setting system property “org.jbehave.core.configuration.silentsuccess”.

JBehave BDD Testing Interview Questions

JBehave Interview Questions # 11) Can I insert comments in the textual scenarios?

A) Yes, at various levels:

In scenario title, which allows free text up the first step starting word of the scenario (e.g. the first Given), provided this is at the beginning of a line. Any keyword not at the beginning of a line, i.e. not preceded by a newline character, will be ignored.
Between executable steps, using keyword “!–” (which can be changed via i18n properties).
Between example table rows, using separator “|–“.

JBehave Interview Questions # 12) BDD focuses mostly on what?

A) BDD focuses on:

  • Where to start in the process
  • What to test and what not to test
  • How much to test in one go
  • What to call the tests
  • How to understand why a test fails

JBehave Interview Questions # 13) What are the principles of BDD?

A) Test-driven development is a software development methodology which essentially states that for each unit of software, a software developer must:

  • define a test set for the unit first;
  • make the tests fail;
  • then implement the unit;
  • finally, verify that the implementation of the unit makes the tests succeed.

JBehave Interview Questions # 14) What are Stories, Scenarios and Steps in BDD?

A) BDD revolves around the concept of a Story, which represents an automatically executable increment of business functionality. At its core, a Story comprises of one or more Scenarios, each of which represents a concrete example of the behavior of the system. Each Scenario comprises of a number of executable steps.

JBehave Interview Questions # 15) Can you explain Stories, Scenarios, and Steps in BDD with an example?

A story is a collection of scenarios

Narrative:
In order to communicate effectively to the business some functionality
As a development team
I want to use Behaviour-Driven Development

Scenario: A scenario is a collection of executable steps of different type

Given step represents a precondition to an event
When step represents the occurrence of the event
Then step represents the outcome of the event

Scenario: Another scenario exploring different combination of events

Given a precondition
When a negative event occurs
Then the outcome should be captured
Given, When and Then are also called BDD Keywords

JBehave Interview Questions # 16) What is Gherkin language?

A) Gherkin is the language that Cucumber uses to define test cases. It is designed to be non-technical and human readable, and collectively describes use cases relating to a software system.

The purpose behind Gherkin’s syntax is to promote Behavior Driven Development practices across an entire development team, including business analysts and managers.

JBehave Interview Questions # 17) Gherkins files have which file extension?

A) All Gherkin files have the .feature file extension. They contain a single Feature definition for the system under test and are an executable test script.

JBehave Interview Questions # 18) Can you write JBehave Story Syntax?

A) JBehave Syntax – JBehave’s syntax is supported by the RegexStoryParser:

A story is a collection of scenarios

Narrative:
In order to communicate effectively to the business some functionality
As a development team
I want to use Behaviour-Driven Development

Lifecycle:
Before:
Given a step that is executed before each scenario
After:
Outcome: ANY
Given a step that is executed after each scenario regardless of outcome
Outcome: SUCCESS
Given a step that is executed after each successful scenario
Outcome: FAILURE
Given a step that is executed after each failed scenario

Scenario: A scenario is a collection of executable steps of different type

Given step represents a precondition to an event
When step represents the occurrence of the event
Then step represents the outcome of the event

Scenario: Another scenario exploring different combination of events

Given a [Precondition]
When a negative event occurs
Then the outcome should [be-captured]

Examples:
|precondition|be-captured|
|abc|be captured |
|xyz|not be captured|

JBehave Interview Questions # 19) Can you explain about Step Annotations with examples?

A) Step Annotations
JBehave supports the following method step annotations:

@Given
@When
@Then
@Alias
@Aliases
@Pending

Each annotation holds a regex pattern as value, which is used to match the candidate steps to the textual step:

@Given(“a stock of symbol $symbol and a threshold of $threshold”)
public void aStock(String symbol, double threshold) {
// …
}

@When(“the stock is traded at $price”)
@Alias(“the stock is exchanged at $price”) // single alias
public void theStockIsTradedAt(double price) {
// …
}

@Then(“the alert status should be $status”)
@Aliases(values={“the trader should be alerted of status $status”,
“the alert status is at $status”}) // multiple aliases
public void theAlertStatusShouldBe(String status) {
// …
}

JBehave Interview Questions # 20) Can you explain about Scenario Annotations?

A) Scenario Annotations – JBehave supports the following method scenario annotations:

@BeforeScenario
@AfterScenario

The @BeforeScenario and @AfterScenario annotations allow the corresponding methods to be executed before and after each scenario. Optionally, the ScenarioType can be specified to execute only upon that type, e.g. for scenarios parametrized by examples.

In addition, @AfterScenario allows the setting of an optional Outcome value, which specifies whether the method should be executed depending on the outcome of the scenario:

@BeforeScenario
public void beforeEachScenario() {
// …
}

@BeforeScenario(uponType=ScenarioType.EXAMPLE)
public void beforeEachExampleScenario() {
// …
}

@AfterScenario // equivalent to @AfterScenario(uponOutcome=AfterScenario.Outcome.ANY)
public void afterAnyScenario() {
// …
}

@AfterScenario(uponType=ScenarioType.EXAMPLE)
public void afterEachExampleScenario() {
// …
}

@AfterScenario(uponOutcome=AfterScenario.Outcome.SUCCESS)
public void afterSuccessfulScenario() {
// …
}

@AfterScenario(uponOutcome=AfterScenario.Outcome.FAILURE)
public void afterFailedScenario() {
// …
}

Behavior-Driven Development Interview Questions

21) Can you explain about Story Annotations?

A) Story Annotations – JBehave supports the following method story annotations:

@BeforeStory
@AfterStory
The @BeforeStory and @AfterStory annotations allow the corresponding methods to be executed before and after each story, either a GivenStory or not:

@BeforeStory // equivalent to @BeforeStory(uponGivenStory=false)
public void beforeStory() {
// …
}

@BeforeStory(uponGivenStory=true)
public void beforeGivenStory() {
// …
}

@AfterStory // equivalent to @AfterStory(uponGivenStory=false)
public void afterStory() {
// …
}

@AfterStory(uponGivenStory=true)
public void afterGivenStory() {
// …
}

22) What are Stories Annotations? Explain with examples?

A) Stories Annotations – JBehave supports the following method stories annotations:

@BeforeStories
@AfterStories
The @BeforeStories and @AfterStories annotations allow the corresponding methods to be executed before and after a collection of stories:

@BeforeStories
public void beforeStories() {
// …
}

@AfterStories
public void afterStories() {
// …
}

23) What are Parameter Annotations?

Parameter Annotations – JBehave supports the following parameter annotations:

@Named

Parameter annotations are used in parameter injection.

24) What are Configuration Annotations?

A) Configuration Annotations

JBehave supports the following configuration annotations:

@AsParameterConverter
@Configure
@UsingEmbedder
@UsingSteps
@UsingGuice
@UsingNeedle
@NeedleInjectionProvider
@UsingPico
@UsingSpring

25) What are Candidate Steps?

A) Candidate Steps – JBehave uses method annotations in Java classes to associate an executable Java method to a StepCandidate. Each step candidate corresponds to one Java method and to one StepType. A step candidate holds the regex pattern contained in the annotation value, which is used to do the matching with the textual steps in the scenarios.

26) What are Pending Steps?

A) Pending Steps – JBehave is designed to allow textual stories to be written before the implementation, i.e. to let the specification of the behavior drive the development.

For this reason, with steps that do not match any method in the Steps class, which are called pending steps, it does not fail by default. By marking a step as pending, it’s simply telling the scenario writer that it’s not yet implemented and correspondingly it will not execute any steps that follow in the same scenario.

27) Where do you locate stories in JBehave?

A) Locating Stories – In JBehave, stories can be located locally, i.e. in the class path, or externally, locatable via URLs. Depending on where the stories are located, an appropriate StoryLoader needs to be defined:

  • LoadFromClasspath for stories located in classpath.
  • LoadFromURL for stories located via URL.
  • By default, JBehave expects stories to be written in plain text, but also supports other formats as long as these can be converted to a textual which is then parsed by the StoryParser.

28) What are Story Reporters in JBehave?

A) Story Reporters – Reporting is an essential element of BDD as it allows to monitor the outcome of the stories that have been run. At the heart of JBehave’s reporting is the StoryReporter, to which events are reported as they occur.

  • Currently, the story reporters supported are:
  • ConsoleOutput: a text-based console output
  • IdeOnlyConsoleOutput: a text-based console output, which only reports events when running in IDEs (Eclipse and IDEA supported).
  • TxtOutput: a text-based file output
  • HtmlOutput: an HTML file output
  • HtmlTemplateOutput: an HTML template-based file output. By default, a
  • Freemarker-based template processor is used but a different implementation based on a different templating system can be provided.
  • XmlOutput: an XML file output
  • PostStoryStatisticsCollector: collects statistics and stores them as properties after story is run
  • DelegatingStoryReporter: used by the StoryReporterBuilder to delegate to any number of reporters as a proxy.

The StoryReporterBuilder allows configuring multiple story reporters with pre-configured formats: CONSOLE, TXT, HTML, HTML_TEMPLATE, and XML

29) How do you Stories in JBehave?

A) Running Stories – JBehave is designed to be embedded in different development environments. The JBehave Core module contains support for running stories as JUnit tests – which can be run either in your favorite IDE or in your command-line build that supports JUnit tests. Other unit testing frameworks, e.g. TestNG or Spring Test, can also be used very easily.

You can also run stories using the JBehave Ant tasks or Maven goals, which provide a facade around the Embedder functionality.

JBehave provides the Embedder as the core entry point to running stories. The Embedder can be configured in multiple ways,

30) What are multiple Running modes in JBehave?

A) Multiple running modes – Stories can be run in different modes:

  • as embeddables: An Embeddable is an abstraction of a running mode, which can run a single story, e.g. if extending JUnitStory or can run multiple stories, e.g. if extending JUnitStories. The Embeddable instances allow their configuration.
  • as paths: once we have specified an instance of an Embedder, with its configuration, we run stories specified by paths.

With annotated embedder runner: an AnnotatedEmbedderRunner is an implementation of the JUnit Runner, which allows annotated specification of the Embedder to be used to run the stories.

With annotated path runner: an AnnotatedPathRunner is an extension of AnnotatedEmbedderRunner which creates a JUnit suite containing each story path and resolving the path to a human-readable form that plays nicely with any IDE that provides JUnit integration.

Source: JBehave Documentation

Related INTERVIEW QUESTIONS

  1. Elasticsearch Interview Questions
  2. Kibana Interview Questions
  3. Openshift Interview Questions
  4. Kubernetes Interview Questions
  5. Nagios Interview Questions
  6. Jenkins Interview Questions
  7. Chef Interview Questions
  8. Puppet Interview Questions
  9. RPA Interview Questions And Answers
  10. Demandware Interview Questions
  11. Visual Studio Interview Questions
  12. Vagrant Interview Questions
  13. 60 Java Multiple Choice Questions
  14. 40 Core Java MCQ Questions
  15. Anaplan Interview Questions And Answers
  16. Tableau Multiple Choice Questions
  17. Python Coding Interview Questions
  18. CSS3 Interview Questions
  19. Linux Administrator Interview Questions
  20. SQL Interview Questions
  21. Hibernate Interview Questions
  22. Android Interview Questions
  23. Mulesoft Interview Questions
  24. JSON Interview Questions
  25. PeopleSoft HRMS Interview Questions
  26. PeopleSoft Functional Interview Questions
  27. PeopleTools Interview Questions
  28. Peoplesoft Technical Interview Questions
  29. 199 Peoplesoft Interview Questions
  30. 200 Blue Prism Interview Questions

Leave a Comment