Unit Testing As An Aid For API Development

If you follow Test Driven Development (TDD) the first step is always to write your unit tests before you write your code. Well in LabVIEW that doesn’t work out quite so well because you need to have a subvi to drop into your test case.

When trying TDD, the first hurdle you run into is that you need a subvi to drop into your test. This forces you to develop your API first.

That means that before you write the tests you need to give the API a lot of thought. As Fab likes to point out, this makes you the first user of the API. Writing the test first forces you to consider the use cases and figure out exactly what is the best way to pass data and what data each method needs. It ends up making for a much more well-thought-out API.

Looking for some tips for writing great APIs – start here:

Leave a Reply

Your email address will not be published. Required fields are marked *

*