Top Banner
37

Jbehave- Basics to Advance

Jan 23, 2018

Download

Software

Ravinder Singh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Jbehave- Basics to Advance
Page 2: Jbehave- Basics to Advance

Testing Pyramid

Page 3: Jbehave- Basics to Advance

TDD

Page 4: Jbehave- Basics to Advance

Acceptance TDD vs Developer TDD

Page 5: Jbehave- Basics to Advance

BDD

Page 6: Jbehave- Basics to Advance

Why BDD

Page 7: Jbehave- Basics to Advance

What’s Changed

Page 8: Jbehave- Basics to Advance

QA Myths

You only need to unit test. TDD testing is sufficient.

You can reuse unit tests to build a regression test suite.

We no longer need testers, as Developer have adequate coding skills.

Unit test remove the need of manual testing.

User Acceptance testing is no longer needed.

Automation in so early phases is impossible.

TDD/BDD is applicable on every project.

Developers and testers are like water and oil.

Page 9: Jbehave- Basics to Advance
Page 10: Jbehave- Basics to Advance

Unit Testing Frameworks in Java

JUnit

Cactus

StrutsTestCase

TestNG

jMock

Grinder

Jetif

Unitils

p-unit

XMLUnit

Ejb3Unit

FEST-Swing

Ripplet

Feed4JUnit

...

Page 11: Jbehave- Basics to Advance

Junit vs TestNG

Page 12: Jbehave- Basics to Advance

JUnit

@Test Annotation

JUnitCore

Exception Test

@Ignore

Timeout Test

TestSuite

Before and After Annotations

@BeforeClass and @AfterClass

Parameterized Test

Page 13: Jbehave- Basics to Advance

TestNG

Annotations

Exception Test

Ignore Test

Timing Test

TestSuite

Parameterized Test

Test Dependency

Group Test and Dependency

Page 14: Jbehave- Basics to Advance

Maven

JUnit + Maven

TestNG + Maven

Page 15: Jbehave- Basics to Advance
Page 16: Jbehave- Basics to Advance
Page 17: Jbehave- Basics to Advance

1. Write Story

Create New Maven project using MyNumber class used in previous examples.

Add Jbehave plugin in IntelliJ

Add dependencies of Jbehave and Junit

Add a new story under test resources folder

Page 18: Jbehave- Basics to Advance

2. Map Steps to Java

Create a POJO and implement the Given, When, Then Steps

Page 19: Jbehave- Basics to Advance

3. Configure Stories

Implement a TestRunner class by extending class JUnitStory.

Override the configuration and stepsFactory methods.

Ensure that story name would be same as test name with _ updated for each Camel Case.

This is because of the configuration used for loading of story, i.e., MostUsefulConfiguration

Page 20: Jbehave- Basics to Advance

4. Run the Story

Run the story same as Junit test

Page 21: Jbehave- Basics to Advance

5. View Reports

Verify the reports under target/jbehave folder

Page 22: Jbehave- Basics to Advance
Page 23: Jbehave- Basics to Advance

JUnit-enabled Embeddables

JUnitStory: provides a one-to-one mapping with the textual story.

JUnitStories: provides a many-to-one mapping with the textual story paths

Page 24: Jbehave- Basics to Advance

Story Syntax

JBehave Syntax

Narrative:

Lifecycle:

Before:

After

Scenario

Gherkin Syntax

Narrative:

Background:

Given:

Scenario/Scenario Outline:

Gherkin's Background element corresponds to the JBehave Lifecycle Beforeelement.

JBehave also supports a Lifecycle After element which is not currently available in Gherkin.

Page 31: Jbehave- Basics to Advance

Prioritizing Steps

For cases in which multiple candidates can match the same textual step, the first candidate that matches is used to create an executable step.

To prioritize one candidate over another simply set a non-zero positive priority.

Page 32: Jbehave- Basics to Advance

Story Path’s

Class-path – Arrange in any folder hierarchy within project.

URL-Loader (Running Remote Stories) – Specify the path from a URL

Google-docs (Running Remote Stories) – No more supported, due to change in google authorization, but can be customized, if needed for a project.

Page 34: Jbehave- Basics to Advance

Customizing Reports

Specify the FTL File

Define a custom Template that will use the FTL file

Use this reporter in TestRunner

Page 35: Jbehave- Basics to Advance

UI Testing

Use Serenity Stories

Specify properties in serenity.properties or from maven command line options

Specify “aggregate” goal to aggregate reports.

Page 36: Jbehave- Basics to Advance

REST APIs Testing

Use plugin serenity-rest-assured to invoke rest APIs

Page 37: Jbehave- Basics to Advance

CI Setup - Jenkins

Download Jekins from https://jenkins.io/download/

Install Jenkins.