If you’re reviewing someone’s code and see that the developer is asserting on the tests on
While dealing with a complex domain and not having nice Gherkin-based tests, the best you can…
I used to write test names on PHP like
public function testThatSomethingIsHappeningWhenSomeConditionIsSatisfied(): void {}
And it worked well for me all this time.
Despite other arguments against using constants in test, there is one more.
You can not make a constant private, even though you don’t use it in the rest of the codebase, if the constant is being used in the tests.
Sometimes I want to test the implementation — like assert that some external calls are done, that some method is called no more than 1 time, or something similar. I usually use unit tests for that.
I like to use constant literals in tests instead of constants itself.
When we’re looking at code — we can see how it works, we can see that data comes inside, how is it being processed and how returned.
But often nobody can say why someone wrote this code.
Currently I’m working on library which is going to read, modify and write IPTC tags for images.
It means I’m working with file-system and image functions integrated in the language. They work with real FS objects…