Published inCodeX·May 12Member-onlyWhat is a user story? Debunking the mythsA user story, as initially conceived by XP, is not a task, a request, or a requirement. — User stories are not technical Tasks masked as user stories are implementation details. It’s easy to get entangled in details and lose focus on the real goals. “Tech stories” are developers’ to-dos since they materialize what they have in mind to accomplish something meaningful. But what is that meaning? …User Story Card7 min readUser Story Card7 min read
Published inCodeX·May 6Member-onlyUnit Testing: Values and PrinciplesWhat’s a unit test? A function or a class test? A behavior test? Can it interact with the outside? That’s irrelevant if we don’t start with why we do testing in the first place. — Why do we write tests? I heard sentences like “because we need to have coverage”, “if you have a public class it needs a test”, and “because it’s part of our methodology”. None of that addresses the reasons why we test things and we end up with a mechanical and…Testing11 min readTesting11 min read
Published inBetter Programming·Mar 16Member-onlyStory Slicing, a Practical GuideUser stories can always be broken down into smaller, more consumable pieces. Let me tell you how. — Why split? Make sure you read Part I first: The benefits of breaking down user stories How breaking down problems into smaller, more consumable pieces can improve predictability, feedback cycles, and…medium.com When to split? Should a user story always be split? My rule of thumb is to split always; not because it’s big but due to all the benefits of splitting which greatly exceed their overhead. …Software Engineering8 min readSoftware Engineering8 min read
Published inBetter Programming·Feb 8Member-onlyMisconceptions About Domain-Centric ArchitecturesDiscussing the benefits of segregating business and technical code and tackling common misconceptions. — ‘Domain’ is short for ‘business domain’ if the intent is commercial. However, the domain is used here in a broader sense to refer to the real-world problem the app is set out to solve (e.g., a to-do list, an online shop, or a game).Clean Architecture8 min readClean Architecture8 min read
Published inCodeX·Nov 22, 2022Deploying a Kotlin app to Railway (a Slack bot)We will deploy a “Hello world” Slack bot to Railway, sourced from GitHub (written in Kotlin). — Now that Heroku has no free plan anymore, it’s time to find a new home for our experimental JVM apps. Railway does the job. 1. Codebase Create a new Kotlin project. If you haven’t yet made git init, you should do it now. Make sure you have a .gitignore …Railway3 min readRailway3 min read
Published inCodeX·Nov 7, 2022The Testing Library meets SeleniumThe Testing Library enables testing as a user. It’s available for multiple JavaScript frameworks (e.g. React, Vue, Cypress). I realized it was possible and valuable to bring it to Kotlin’s Selenium. — The more your tests resemble the way your software is used, the more confidence they can give you. (Kent C. Dodds) What I developed a set of custom Selenium locators (e.g. ByRole, ByText) that wrap the corresponding Testing Library queries (specifically, the DOM Testing Library):Automated Testing6 min readAutomated Testing6 min read
Oct 14, 2022Selenium waitsWaiting for things to happen can be a source of slow and flaky tests. Let’s learn how to properly wait with Selenium (Kotlin). — Implicit wait In Selenium, you can query a page with: // wait until it's found, else throw a timeout exception driver.findElement(By.id("4-door")) // wait until at least one element is found, else return empty list when the the time out is reached driver.findElements(By.tagName("mat-option"))Selenium4 min readSelenium4 min read
Published inCodeX·Oct 4, 2022Member-onlyA testing strategy for a domain-centric architecture (e.g. hexagonal)I’ll propose a testing strategy for the hexagonal architecture. — Hexagonal architecture The hexagonal architecture and the clean architecture are domain-centric architectural patterns. They’re powerful and adaptable to your needs; even simple apps like command-line tools benefit from centralizing the domain (to separate the I/O from the actual algorithm). Here’s what you need to know: The main principle is that the app…Hexagonal Architecture11 min readHexagonal Architecture11 min read
Published inCodeX·Sep 6, 2022Member-onlyA vertical testing strategyOne of the goals of automated testing is to support you while refactoring, which is a continuous task. Tests should not be in the way. Let’s see how. — 📝 I’ll use the Arrange; Act; Assert terms (the same as Given; When; Then), which is the way tests should be split. A flawed strategy I often see codebases that rely on low-level unit tests to test everything; there are just a few high-level tests for happy cases. I think this derives from…Automated Testing11 min readAutomated Testing11 min read
Published inCodeX·Aug 31, 2022Member-onlyDecoupling tests from implementation detailsOne of the goals of automated testing is to support refactoring but many times, they get in the way. Tests should aim to define what is intended (behavior); not how it’s implemented (details). — Refactoring is a continuous task so we should reduce the exposure to details. Also, tests should not hold us back when evolving the architecture. A good test suite enables coding to be fun. Write your tests in such a way that as many implementation details as possible could be changed…Automated Testing7 min readAutomated Testing7 min read