Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cucumber Cookbook

You're reading from   Cucumber Cookbook Over 35 hands-on recipes to efficiently master the art of behaviour-driven development using Cucumber-JVM

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785286001
Length 162 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Shankar Garg Shankar Garg
Author Profile Icon Shankar Garg
Shankar Garg
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. Writing Feature Files FREE CHAPTER 2. Creating Step Definitions 3. Enabling Fixtures 4. Configuring Cucumber 5. Running Cucumber 6. Building Cucumber Frameworks Index

Overriding the Cucumber Options

Sometimes, depending on the requirements, we would like to override default Cucumber behavior, such as reporting or the project structure, and so on. We can configure Cucumber via the Terminal, but mostly we run Cucumber with JUnit. So how do we configure Cucumber with JUnit Runners, let's see this in our next section.

How to do it…

  1. Add @CucumberOptions to the RunCuckeTest.java class and import Cucumber.api.CucumberOptions. This is how the updated code for RunCukeTest.java should look like:
    package com.CucumberOptions;
    
    import org.junit.runner.RunWith;
    import Cucumber.api.CucumberOptions;
    import Cucumber.api.junit.Cucumber;
    
    @RunWith(Cucumber.class)
    @CucumberOptions(  
    //your Cucumber Options code goes here
    )
    public class RunCukeTest {
    }
  2. Now, let's specify configurations where our Feature files and Step Definitions are located and which Tags are used. This is how the code for RunCukeTest.java should look like:
    package com.CucumberOptions;
    
    import...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image