Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you think Unit Tests are a good way to show your fellow programmers how to use an API?

Tags:

unit-testing

Do you think Unit Tests are a good way to show your fellow programmers how to use an API?

I was listening to the Stackoverflow Podcast this week and I now realize that unit testing is not appropriate in all situations (I.E. it can cost you time if you go for 100% code-coverage). I agree with this as I have suffered from the "OCD code coverage disorder in the past), and have now mended my ways.

However to further appropriate my knowledge of the subject, I'd like to know if unit testing is a good way to bring in new programmers that are unfamiliar with the project's APIs. (It sure seems easier than just writing documentation...although I like it when there's documentation later...)

like image 541
leeand00 Avatar asked Dec 03 '22 16:12

leeand00


1 Answers

I think Unit testing is a fantastic way to document APIs. It doesn't necessarily replace good commenting or API docs but it is a very practical way to help people get into the nitty gritty of your code. Moreover good unit testing promotes good design, so chances are your code will be easier to understand as a result.

like image 79
Ish Avatar answered Jan 03 '23 09:01

Ish