Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
plusgut60137yjust you.
jk: i thought the same in the beginning, but that was because I was doing it wrong. Nowadays i really appreciate it and actually like writing tests.
But the important part: do them before you actually implement the stuff. -
wil222887yFunctionality testing is a must have in more complex programs. It is especially useful when doing web development where a small change could often break something you wouldn't think of thanks to the type handling of JS and PHP.
-
Im just starting out but I don't see why they are useless. They might be in a project of 500 lines. But in a project with 50 files multiple controllers they cannot be missed
-
plusgut60137y@Codex404 i do it even with small 500 loc projects. It saves my day, when I add feature b and notice that because of that the already implemented feature a breaks, because of the changes. And that during the development process, which means less pain afterwards.
-
@plusgut indeed, but a 500 lines project is normally still something which can be tested pretty easily by hand.
-
boom5217yIf you feel that they are unnecessary or you dont have a legit reason to implement them.. They probably are overrated for your project. For example, im not sure that for a small startup it will be a wise idea spending time in those when you need functionality that might lead to money..
-
devios157017yUnit tests are super valuable, but not everything is unit-testable. I've worked with managers and CTOs that think that the codebase needs 100% unit test coverage.
Well that just doesn't make sense. Unit test your model classes and atomic entities that make sense to be tested in isolation. When you have to start writing test harnesses and test stubs, or adding dependency injection just so you can stub out real classes for test proxies, that's when it starts getting real messy and now you're actually introducing more chance of bugs just to make your software testable. -
@devios1 a colleague of my who was on a project for a dutch tv station did have 100% coverage for their website.
But normally its about 90% right? -
devios157017y@Codex404 Websites are a bit different because you can actually script user interface interactions, which means in some cases you can actually get 100% coverage. Usually user interfaces are not easily unit testable though on other platforms. I can't say what a typical code coverage is.
-
@kaqqao unit tests dont only test functions but also helps as documentation on how a certain piece of code has to work, what it does and types it expects.
-
I, on the other hand, could not appreciate DOM / GUI testing. Automating the clicks? There are so many cases to consider. Enlighten me, masters.
-
wil222887y@nikolatesla I think that no method is perfect... The different possibilities just grow exponentially in most GUI. But testing a lot of user cases can already help a lot. Creating a test doesn't take much time, but if you do something wrong, you will know it before putting it on the master branch/on production :)
If you do correct unit tests on all the functions that need it, you will also reduce errors. -
@nikolatesla I've never done it myself but if MDN would do gui tests to see if every link works the website would be much more usable.
Is it just me, or are unit tests just overrated?
undefined