The at_exit function

Traditionally, in functional testing, a clean up/tear down script would be run in something called an After hook. These hooks are part of the Cucumber DSL and are designed to execute when a scenario has finished. Cucumber example: After do |scenario| if scenario.failed? MultiLogger.clean_logs end end There is a drawback to these hooks where they will fail to run when certain exit codes are returned from the scenario or the program is interrupted....

August 23, 2023 · 2 min · 255 words · Thomas Feathers

TiL: Generating numerous FakerMaker objects in one call

Trying to generate numerous, realistic-looking objects for automation testing can be difficult. Using FakerMaker to do just that is preferable; using factories with Faker to dynamically create the test data you need in whatever format you need, is far better than using fixtures. But what if you needed more than one object of the particular factory that you have created? Creating a factory We can use Faker and FakerMaker to create an individual factory for an API request body like this:...

August 22, 2023 · 2 min · 309 words · Tomos Griffiths

FakerMaker Chaos Mode Update

TL:DR Level up your testing by introducing some chaos to your test data. FakerMaker is an incredible factory builder used to generate test data. When introduced to a test-pack (alongside Faker), it elevates tests by introducing dynamic test data to ensure we’re not constantly testing with the same old boring static data. FakerMaker.factory :some_fancy_object, naming: :json do some_required_attribute { Faker::Lorem.sentence } some_optional_attribute_1 { Faker::Lorem.word } some_optional_attribute_2 { Faker::Lorem.word } some_optional_attribute_3 { Faker::Lorem....

June 16, 2023 · 4 min · 672 words · Alexander O'Mahoney

Efficient Cucumber Step Regex Matching

TL:DR Avoid using Cucumber Expression if possible. Using the conventional regular expression Cucumber is key to more flexible, reusable and customisable test code. When writing cucumber step definitions, developers and testers often face difficulties capturing parameters in test steps while ensuring that the steps flow smoothly in natural English sentences. Without a good knowledge of general regex, step definitions can appear clunky, even when using Cucumber Expressions to capture step definitions parameters....

June 7, 2023 · 7 min · 1380 words · Choon Meng Yap

FakerMaker Initialisation

In the world of automation testing, generating realistic-looking test data is a preferred approach to using static fixtures. FakerMaker is a Ruby gem that allows you to do just that; using factories to create the test data you need. It can be used with Faker to dynamically generate test data. Initialisation We can use Faker and FakerMaker to create a factory for an API request body like this: require 'faker' require 'faker_maker' FakerMaker....

May 17, 2023 · 2 min · 333 words · Mark Isaac