3

I often listen people talk about unit test. But I don't know the exact apperance of it, especially in Linux C code. I know that for VisualStudio this kind of tool will provide some template? to do unit test, but how to make one for Linux general C code. Could anyone show me an example? Or maybe show me how to do TDD for Linux C code? It's mysterious for me. Thanks!

1 Answer 1

3

Unit Testing is a type of automated test which tests individual units of functionality. It's especially useful during initial development and for ensuring that changes don't break your program, which is invaluable when you refactor. You can read more here: http://en.wikipedia.org/wiki/Unit_testing

Unit testing became a big deal with Extreme Programming and Test Driven Development. With that, a large number of unit testing frameworks sprung up.

Which answers your second question. To do unit testing in C, you'll need a unit testing framework for the language. Fortunately, there are a variety available that you can just use, so you needn't worry about creating your own: http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C

If you choose to do your own, you'll need to find a way to attach tests with units of functionality, ensure they are all run when you run your program, and have a way to remove them easily for deployment. Macros will likely be a key.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.