---
title: "Comment by Anthony Fung on \"Keeping Tests Valuable: Be Careful With Regressions!\" | Hashnode"
description: "A very comprehensive article! In my experience there are two things that we should be careful of when writing tests to avoid potential false outcomes. Firstly,"
url: "https://hashnode.com/posts/keeping-tests-valuable-be-careful-with-regressions/6424753dc22b33a63ad94fdd/comment/6424c8fcbb5fefa80796c518"
---

[Discussion](https://hashnode.com/posts/keeping-tests-valuable-be-careful-with-regressions/6424753dc22b33a63ad94fdd)

Comment [Keeping Tests Valuable: Be Careful With Regressions!](https://hashnode.com/posts/keeping-tests-valuable-be-careful-with-regressions/6424753dc22b33a63ad94fdd)

[Anthony Fung](https://hashnode.com/@anthonyf)

[Mar 29, 2023](https://hashnode.com/posts/keeping-tests-valuable-be-careful-with-regressions/6424753dc22b33a63ad94fdd/comment/6424c8fcbb5fefa80796c518)

A very comprehensive article!

In my experience there are two things that we should be careful of when writing tests to avoid potential false outcomes.

Firstly, we should try to control all variables in the test. If a function relies on the date, and we use something like `DateTime.UtcNow`, there could be times of the month where this fails but passes at others. In this case, a good idea is creating a separate 'time' service where we can mock such values.

Another is when testing logic that has some aspect of concurrency, as the threading can potentially complete in a different order each time. In this case, it's best to try to get the logic to run single threaded for the tests, if possible.

[Rafael dos Santos Miguel Filho](https://hashnode.com/@ThePragmaticEngineer)

[Mar 30, 2023](https://hashnode.com/posts/keeping-tests-valuable-be-careful-with-regressions/6424753dc22b33a63ad94fdd/comment/6424c8fcbb5fefa80796c518#reply-6424eb4ebb5fefa80796c90d)

Thanks for reading! I agree with what you said, we need to be aware of these details too!
