r/learnjava • • Aug 23 '16

What kind of tests should I write as a software developer?

https://pawelniewiadomski.com/2016/08/22/what-kind-of-tests-to-write-when-developing-software/?utm_source=reddit&utm_medium=referral&utm_campaign=what-tests-to-write&utm_content=learnjava-2016-08-23
0 Upvotes

3 comments sorted by

2

u/nutrecht Aug 24 '16

The article of James O Coplien you link to and copied the best practices from is controversial at best and just plain idiocy in many places. Just a single example (the worst offender):

Throw away tests that haven’t failed in a year.

This is completely moronic. Tests are there not to show your software works now but also to safeguard it from regressions in the future.

Having a good testing strategy is important. You don't want to put too much effort in software that's likely to be thrown away in a few months. You also don't want to test everything multiple times because when you refactor software you also need to refactor tests.

But this article helps no one. Grand statements like "TDD is dead" or "you can test X with either a system test or a unit test, use a system test" might look nice in your post but don't offer any substance and are plain wrong in many contexts.

Also please keep in mind that this is a sub for beginners. Taking what you said there as gospel is likely going to do them more harm than good.

0

u/msdkflskdf Aug 25 '16

At first it could be moronic (about throwing tests that do not fail) but think about it. If you're working on a daily basis on a project and there are tests that do not fail occasionally for a long time they don't bring value. I saw people testing getter/setter, simple methods that basically do nothing and other stupidity, I guess he was referring to test like that. At least I am referring to tests like that. And yes people write those kinds of tests.

You get one point right - it all depends on the context and that's the most important thing in my point of view. The post was a result of a conversation we had internally - one of the developers from other team was forcing me to write a silly test, because in his PoV everything should be tested. That's wrong approach. He lives in a different context than our team and doesn't understand that.

I see junior developers forced to write stupid tests that don't bring much value and they are afraid to break the cycle. So I believe they can benefit from another perspective.

4

u/[deleted] Aug 23 '16

Fizzbuzz, and I think that's pretty much it.