DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • COM Design Pattern for Automation With Selenium and Cucumber
  • 7 Easy and Effective Tips for Learning a New Programming Language
  • 5 Life Hacks to Protect Your Project from Escaped Defects
  • Cypress vs. Selenium: Choosing the Best Tool for Your Automation Needs

Trending

  • Docker Base Images Demystified: A Practical Guide
  • A Simple, Convenience Package for the Azure Cosmos DB Go SDK
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Agile and Quality Engineering: A Holistic Perspective
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Spice Up Your 'CI/CD Process' With Automation Using Cucumber, Selenium, and Kotlin

Spice Up Your 'CI/CD Process' With Automation Using Cucumber, Selenium, and Kotlin

This article shows how to use Cucumber, Selenium, and Kotlin in your CI/CD process in four easy steps.

By 
Ashok Gudise user avatar
Ashok Gudise
·
Sep. 26, 22 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
3.4K Views

Join the DZone community and get the full member experience.

Join For Free

Continuous Integration & Continuous Deployment

Imagine you are working on a two weeks sprint, and your agile teams have different assignments that can only be tested through Integration Tests, which may take numerous builds in shorter periods. I still remember that a Build Engineer yelled at me for asking for three builds within an hour. With the power of CI/CD, 60% of this problem is solved with Rapid releases with just a click of the mouse or build hooks.

Problem Statement

Your PL/SQL Developer has optimized an SQL Query which works like a charm, now, he wanted to tweak the Stored Procedure furthermore, and he wanted a Quality Engineer to do the regression testing.

App Developer has fixed one issue that has something to do with user-login sessions or some complex logic that renders a huge list of items. It worked just fine in his local machine, but he wanted a Quality Engineer to do the regression testing.

Also, the Web Analytics team wanted to add tags and test the trends in a repeated manner, and they wanted a Quality Engineer to do the regression testing.

I hope you got my point now! These teams want to do these changes repeatedly (needless to mention the number of the builds), and they all want to perform regression tests on a Dev or SIT environment. I see this as almost a Six Months Project based on the team's availability and other dependencies.

And...

Adding Browser Automation to your CI/CD is the best complementing solution, but how you do that is something that really matters!

Technical Stack

I choose Cucumber, Gherkin, Kotlin, Selenium, JUnit 5, and Spring Boot framework. And IntelliJ Idea & Selenium IDE (Chrome Browser Add-On), and Chrome Webdriver (if you are running local) or Selenium Grid.

Gherkin + Cucumber

We do not go into detailed discussion about these topics as many blogs are available to explain what they are; I have added a couple of them at the end of this blog. On a high level, Gherkin is a plain English test, a well-known standard representation of Behavior Driven Development (BDD in short form) scripts. Cucumber is a testing tool that supports BDD frameworks to run your test cases written in Java, Ruby, Node, and many other languages. That association is represented as Glue in Cucumber.

You will bridge the ".feature" files written in the Gherkin language and associate them to the steps with the choice of your favorite programming language.

Cucumber + Selenium IDE

Browser Automation is often a tedious process if you do not use the correct tools. In the preliminary step to capture browser elements, if you right-click on your web browser and then select the web component by 'inspect element,' it takes forever to capture these elements in a complex flow. And the quickest possible way to capture these is by using Selenium IDE ( A Chrome Browser Add-On). Add the plugin, click the 'REC'ord button, and navigate to your complete flow. When you are done with the flow, Selenium will provide you with a wide variety of options for every single component that you interact with in your flow (CSS Selector, XPath, Relative XPath, Id and Name, XPath is always my safe bet if you ask me).

Kotlin + Cucumber

As I mentioned in my previous blog post, Kotlin eliminates most of the boilerplate code and gives you many powerful features like Null Safety, Safe Calls, Lazy Properties, Scope Functions, and last but not least, Coroutines.

If you are familiar with writing Cucumber test scripts, we often write these using the Page Object Model. It makes it much easier when using Kotlin to do this.

Now Let's Write Some Code (In Just Four Steps)

1. Write a Cucumber feature file as shown below. (Remember, the Gherkin language is just plain English.)

Write a Cucumber feature file as shown below. (Remember, the Gherkin language is just plain English.)


2. Write a Page Object file with web elements that you have captured with Selenium IDE.


 Write a Page Object file with web elements that you have captured with Selenium IDE.


3. Glue Your "search-my-name.feature" file with "SearchSteps.kt" using "SearchPage.kt" elements.


 Glue Your "search-my-name.feature" file with "SearchSteps.kt" using "SearchPage.kt" elements.


You are All Set!

4. You can do either of these to run this test.

Right click on Test Class and Run As JUnit Class

or

Right Click on the search_my_name.feature and run

or

Run the "mvn clean test" command

You can do either of these to run this test.

5. Now the Bonus Part!

Check project-root/target/cucumber-reports/cucumber.html and open it in any browser.

Check project-root/target/cucumber-reports/cucumber.html

That's all for now, Happy Learning!

Contextual design Google Chrome Integrated development environment Regression testing Ruby (programming language) Cucumber (software) Element Kotlin (programming language) Testing Selenium

Opinions expressed by DZone contributors are their own.

Related

  • COM Design Pattern for Automation With Selenium and Cucumber
  • 7 Easy and Effective Tips for Learning a New Programming Language
  • 5 Life Hacks to Protect Your Project from Escaped Defects
  • Cypress vs. Selenium: Choosing the Best Tool for Your Automation Needs

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!