AI Briefing
KO

Kurly Shares Case Study on Writing Readable Test Code by Applying the BDD Pattern

·2020.02.24 00:00

Key point

The Kurly team implemented a reward points expiration date calculator feature using the BDD pattern, improving both the readability and writing experience of test code.

Details

The Kurly development team shared a case study through an internal tech-sharing session on introducing the BDD(Behavior Driven Development) pattern and applying it to a real work feature, the reward points expiration date calculator. To solve readability issues in existing test code, they combined the Nested structure of JUnit 5 with a BDD style.

Reward Points Expiration Policy and Test Implementation

The reward points expiration date calculator supports three policies based on the payout date: the last day of the same quarter next year, the same date next year, or N days later. The team implemented this complex logic in BDD style while adhering to the principle of writing only one test at a time.

  • Policy 1: Last day of the same quarter next year based on payout date (e.g., if paid out on January 1, 2020, it expires on March 31, 2021)
  • Policy 2: Same date next year based on payout date
  • Policy 3: N days after payout date

Improvement Through Pair Programming and Code Review

The initial BDD test code had unclear hierarchical structure, resulting in poor readability. To address this, the code was refined through pair programming and PR(Pull Request) reviews. In particular, strict application of the principle 'write only one test at a time' eliminated unnecessary complexity.

The final test code was written in a style close to natural language, improving it so that even non-developers or new hires could easily understand the business logic. The team evaluated that the BDD pattern increases both the enjoyment and readability of writing tests, and plans to continue experimenting with BDD-based development going forward.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.