---
title: "Comment by Luís Soares on \"12 Tips for Writing Better Automated Tests\" | Hashnode"
description: "Nice article! My 2 cent: Usually, I don&#39;t agree with &quot;Avoid magic numbers or strings&quot;. I wrote an article about it . I prefer DAMP and Evident Dat"
url: "https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6/comment/6021d78e281265375d6436d4"
---

[Discussion](https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6)

Comment [12 Tips for Writing Better Automated Tests](https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6)

[Luís Soares](https://hashnode.com/@lsoares)

[Feb 9, 2021](https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6/comment/6021d78e281265375d6436d4)

Nice article! My 2 cent: Usually, I don't agree with "Avoid magic numbers or strings". [I wrote an article about it](https://levelup.gitconnected.com/when-magic-numbers-are-not-magic-fcdf034295a5). I prefer [DAMP](https://enterprisecraftsmanship.com/posts/dry-damp-unit-tests/) and Evident Data (Kent Beck).

I'd do instead:

```
const userPosts = callToGetUserPosts();
expect(userPosts).toBe(1);
```

which is a self-documenting single-liner.

[Dino Kacavenda](https://hashnode.com/@kaca)

[Feb 9, 2021](https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6/comment/6021d78e281265375d6436d4#reply-60223e04281265375d643da0)

Thank you for reading the article :). I agree with things you wrote in your article, what I meant by avoiding magic values is to approve the readability of tests when you have some complex setups (for example you setup a database to test your repository layer). In those cases, I have found it is very hard to determine what some value means. If values are self-evident like in your example then I completely agree that you can inline the value.

[Luís Soares](https://hashnode.com/@lsoares)

[Feb 9, 2021](https://hashnode.com/posts/12-tips-for-writing-better-automated-tests/60190d3958cc670f3df45ae6/comment/6021d78e281265375d6436d4#reply-60225f71281265375d64434e)

[Dino Kacavenda](https://hashnode.com/@kaca) thanks for reading my article. my point is that there rarely is the need of creating constants. And when there is, perhaps there's a smell around it. maybe you can find a better example 🤓
