Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has anybody used Unit Testing as a way to learn programming?

Tags:

tdd

I understand the concept of Unit Testing as coming up with simple ideas about what your code should output - then outputting it. So it's thinking about what you want a piece of code to do - then making a test to ensure it works.

At which point in learning programming should TDD (unit testing) be incorporated?

Edit: I liked the comment about unit testing as soon as the tools to do it stop becoming magical.

Originally the question came about because I realize I don't have the skills yet to develop a large program, but would like to learn by coming up with ideas for what some piece of code could / should do.

I'm wanting to get into learning by doing and I figure a structured way to do this would help. Python is the language I'm using. Thanks for all the input thus far.

like image 463
Brian Ball Avatar asked Oct 14 '09 21:10

Brian Ball


People also ask

Do developers do unit testing?

Unit testing is the first software testing phase in SDLC and it is usually taken up during the development of the application. These unit test cases are written and executed by software developers.

Why do developers use unit testing?

Unit Testing allows developers to learn what functionality is provided by a unit and how to use it to gain a basic understanding of the unit API. Unit testing allows the programmer to refine code and make sure the module works properly.

Should you write unit tests before code?

It often makes sense to write the test first and then write as much code as needed to allow the test to pass. Doing this moves towards a practice known as Test-Driven Development (TDD). Bluefruit uses a lot of TDD because it helps us to build the right product without waste and redundancies.

Is unit testing a skill?

As an essential software development process, unit testing is a valuable skill to know as a developer.


2 Answers

Unit testing is a huge time saver when you're starting out, because you end up doing a lot of "code, run, debug" cycles while learning. It's that "run" phase that becomes a time suck when you're doing it ad-hoc every time. Also I think beginners tend to introduce more regression problems, which is another huge time sink if you don't catch them right away with a unit test.

like image 191
spieden Avatar answered Oct 15 '22 23:10

spieden


As early as possible. All my hurdles in adopting TDD have been because I've had to break old habits, and change my way of thinking. If I could have thought in terms of TDD from the start I would have found the whole thing much easier.

like image 28
Matthew Vines Avatar answered Oct 16 '22 01:10

Matthew Vines