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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
  1. DZone
  2. Software Design and Architecture
  3. Integration
  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.

Ashok Gudise user avatar by
Ashok Gudise
·
Sep. 26, 22 · Tutorial
Like (1)
Save
Tweet
Share
2.48K 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.

Popular on DZone

  • Handling Virtual Threads
  • How to Use MQTT in Java
  • Memory Debugging: A Deep Level of Insight
  • Integration: Data, Security, Challenges, and Best Solutions

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: