Posts

Canary Testing: A Comprehensive Guide for Developers

Image
  What's Canary Testing , Anyway? Imagine you're a miner with a canary in a cage. If the air is toxic, the canary reacts first, giving you a heads-up. Canary testing works in a similar fashion for your software. Instead of releasing the whole flock (users) into a potentially toxic or buggy environment, you release just one canary (a small subset of users) to test the waters. Why Canary? In the coal mining days, miners used canaries to detect dangerous gases. If the canary stopped singing, it was a sign that something was wrong. In our tech world, our "canaries" are the early adopters who help us sniff out any issues before a full-scale release. Setting Up Your Canary Test Now, let's get our hands dirty. We'll be using go-test for our examples because, well, Go is awesome. Step 1: Feature Flags Start by incorporating feature flags into your code. These nifty toggles allow you to enable or disable certain features at runtime. Perfect for controlling who gets to...

Mock vs Stub vs Fake: Understand the difference

Image
  Introduction Testing software is like putting it through a series of challenges to make sure it's tough enough for real-world use. Whether we're testing each piece individually (unit testing) or how they all work together (integration testing), we need to be prepared for different situations. Sometimes, testing is tricky.There are times, when we need to isolate parts of our code from their dependencies. Also When we examine how different pieces of our application interact with each other.That's where tools like Mocks, Stubs, and Fakes come into the picture. In this Article, We'll explore What is Fake vs Stub vs Mock and their differences. So without delaying further, Let's dive deep into it! Fakes Vs Stubs Vs Mocks Fakes are a way for us to simulate objects and method functionality in our code without actually depending on a real object or method. Stubs are a type of fake that quietly fakes behavior and can return a predefined expected value, while a mock is a ty...

Automated E2E tests using Property Based Testing | Part II

Image
  If you haven't visited Part I , I highly recommend you go through it for a better understanding of this blog. Let's continue 🤠 What is Property-Based testing? Before delving into property-based testing, it's important to understand example-based testing. Traditional, or automated example based testing specifies the behaviour of your software by writing examples of it, each test sets up a single concrete scenario and asserts how the software should behave in that scenario. The problem with example-based tests is that they end up making far stronger claims than they can demonstrate. Consider unit testing as an example. In this method, developers test a single input scenario to ensure a comprehensive evaluation of a specific function or condition's behaviour. It is a widely employed testing approach preferred by most developers. Meanwhile, Property-based tests take these concrete scenarios and generalize them by focusing on which features of the scenario are essential ...

Automated End to End tests using Property Based Testing | Part I

Image
 " Engineers call them edge cases. I call them: what our users do " - Noah Sussman Testing remains a crucial aspect of software development. Software engineers and quality assurance professionals make use of diverse techniques and methodologies to rigorously test applications. However, even with these measures in place, bugs can still emerge. In this modern era, where advanced technologies like chatGPT are surpassing human capabilities in the tech domain, achieving absolute perfection in software property based testing remains a complex task. Do you still believe that unit tests are legit 🧐? Like the quote claims, do we test only what users do? Are manual regression testing and test suite creation still necessary for QA? Well, as we go further we will uncover the answers to these questions. Let's begin with the basics and progress towards developing a test automation platform that may potentially surpass the accuracy of AI (just kidding 😅 or maybe not 🤨). What is Soft...

Go Mocks and Stubs Made Easy

Image
  Testing network stuff like APIs and database calls can be a real pain: I find myself burning way too much time just making mock data, instead of actually doing the tests or assertions. When you make fake mocks, you might end up using wrong guesses or data that's just too unreal or vague. When things (contract) change, you have to dig around and update everything by hand. It's a bit of a headache. I was searching for a more efficient way to imitate HTTP dependencies. I found a great library on Google's GitHub page. The URL is github.com/google/go-replayers . It piqued my interest because it let me record my HTTP dependencies, and hey, it's working out for Google, right? Still, it wasn't all smooth sailing - a couple of issues popped up: Reading and editing the recorded stubs was difficult. Scrubbing sensitive information such as personal details and keys was especially challenging, especially when recording from live production sources. Keeping these stubs fresh w...

Writing test cases for Cron Job Testing

Image
  Understanding Cron Jobs: A Quick Recap Cron jobs is a time-based job scheduler in Unix-like operating systems. It allows you to schedule tasks (or jobs) to run at specified intervals. Now, let's get down to business – testing these Cron jobs to make sure they're doing what they're supposed to do. How can you be certain they're doing what they're supposed to? Enter Cron Job Testing – a crucial step in ensuring the reliability of your scheduled tasks. Writing Effective Test Cases Now, onto the nitty-gritty – writing test cases. The goal here is to cover all possible scenarios and make sure our Cron Jobs are up to the challenge. Identifying Test Scenarios Now, let's get our hands dirty and start crafting some effective test cases. 1. Frequency and Timing: Test that the Cron Job runs at the specified frequency. If it's set to run every hour, make sure it does just that. Check the timing accuracy. We don't want tasks running at 3:05 if they're suppose...

Improving Code Quality and Accelerating Development: The Continuous Testing Way

Image
  Introduction In the fast-changing world of software development, teams struggle to maintain good code quality while shortening development schedules. Continuous Testing (CT) in CI/CD pipelines stands out as a powerful strategy. It allows teams to weave testing directly into their development workflow, offering quick feedback and stronger quality assurance. This article delves into Continuous Testing's core, making it an indispensable role in CI/CD, essential tools, and strategic considerations to optimize your development workflow. Understanding Continuous Testing Continuous Testing is the practice of automating tests to run as part of the software development lifecycle, allowing for immediate feedback on the impact of changes. At the heart of the CI/CD pipeline, it tests and validates every new commit, driving better quality and quicker delivery to end-users. The Role of Continuous Testing in CI/CD Integrating Continuous Testing into CI/CD pipelines revolutionizes how teams app...