From fb05247c33569b7a4b532b2aab130b84156cb2e3 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 15 Feb 2025 17:29:11 +0000 Subject: [PATCH] Add daily email for 2025-02-03 Good software is easy to test --- source/_daily_emails/2025-02-03.md | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 source/_daily_emails/2025-02-03.md diff --git a/source/_daily_emails/2025-02-03.md b/source/_daily_emails/2025-02-03.md new file mode 100644 index 00000000..0a7111a4 --- /dev/null +++ b/source/_daily_emails/2025-02-03.md @@ -0,0 +1,31 @@ +--- +title: Good software is easy to test +date: 2025-02-03 +permalink: daily/2025/02/03/testable +tags: + - software-development + - testing +cta: testing_course +snippet: | + Good software is easy to write automated tests for. +--- + +One piece of criteria for whether some software is good is whether it's easy to write automated tests for. + +I recently worked on a method that was more than 150 lines. + +It was difficult to understand, had too many responsibilities and didn't use dependency injection. + +This made it difficult to test. + +If it was split into several smaller methods or classes, each could be responsible for different aspects and have clear responsibilities. + +Each new method or class could have its own tests to verify its own functionality works. + +It would be easy to understand and identify and fix any issues. + +If dependency injection was used, things can be mocked or changed as needed to make the logic testable. + +If everything is in one large function, the code isn't testable. + +Even if it works now, it will be difficult to change in the future.