A
A
Andrey Salnikov2017-04-24 15:20:44
PHP
Andrey Salnikov, 2017-04-24 15:20:44

If I can't test my code, does that mean I'm not writing it correctly?

A serious dilemma arose.
The client wanted a product picker on the site. On a separate page. Painted how and what should work. The work was done, and everything seems to be fine, but the client said - I want it like this. And it turned out that this Wishlist does not fit with the current system and, although a little, it needs to be redone. Remade but began to appear here and there, various small bugs. And now the client said another Wishlist.
In general, I realized that it would not be bad to write tests. And then a problem arose that neither the server ( PHP, CMS ModxRevo ), nor the front could somehow be tested.
Requests from JS are processed in the snippet by different functions, and as I understand it, these functions can only be tested in conjunction with the class (this opinion was formed from the first PHPUnit example).
And the front is the same. Almost all functions require the presence of HTML rendered on the server. And as soon as I fix the layout on the server, JS can no longer pick up the necessary classes (although this is at least a little, it is solved by the obligatory presence of classes like - .js-* ).
And here is the question - if I see that my code cannot be simply tested somehow, does this mean that I write everything wrong and I need to rewrite it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dark Hole, 2017-04-24
@abyrkov

Most likely this means that you are writing tests incorrectly :)

V
Valera Figol, 2017-05-06
@Kamrit

First, not all code can be covered by tests.
Secondly, if all the same the code can be covered with tests, then it would be better to use TDD development.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question