mercredi 4 mars 2020

How to use SOLID and DRY with Test Driven Development in GO

I have a theoretical question. Here is the example:

Imagine that in this application I have functions that has some tests, as this is a TDD project. All these functions receive the same input and perform a different operation with this input.

I want to validate the input before performing those operations, to make sure that the data is correct.

What I don't understand is the best way of doing this. If I create tests in each one of my _test files to test if the input is correct, I am not following DRY, because I am repeating myself in each different operation. If I create a package to validate the input before each function and test those validations in the validate_test, am I doing a good solution? Or am I contradicting SOLID?

Aucun commentaire:

Enregistrer un commentaire