---
title: "TDD Kata 3 - Refactoring"
url: "https://osherove.com/tdd-kata-3.md"
canonical: "https://osherove.com/tdd-kata-3"
tags: []
author: "Roy Osherove"
description: "Create a Password verifications class or function for the purposes of password verification. Verification will fail if any one of the rules mentioned does"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# TDD Kata 3 - Refactoring

TDD Kata

# TDD Kata 3

Create a Password verifications class or function for the purposes of password verification. Verification will fail if any one of the rules mentioned does not pass.

1. Implement the following rules:

    1. \- password should be larger than 8 chars

    2. \- password should not be null

    3. \- password should have one uppercase letter at least

    4. \- password should have one lowercase letter at least

    5. \- password should have one number at least

    Each one of these should throw an exception with a different message of your choosing

    2. Add feature: Password is OK if at least three of the previous conditions is true

    3. Add feature: password is never OK if item 1.4 is not true.

8\. Assume Each verification takes 1 second to complete. How would you solve  items 2 and 3  so tests can run faster?

## Lessons on this topic

- [Testing Complex Validation Knowledge using Extract & Override](https://courses.osherove.com/courses/the-art-of-unit-testing-and-tdd-master-class-in-net/testing-complex-validation-knowledge-using-extract-and-override/) · The Art of Unit Testing & TDD Master Class in .NET
- [Extract And Override With Validation Logic](https://courses.osherove.com/courses/legacy-code-hero/extract-and-override-with-validation-logic/) · Legacy Code Hero


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
