Can unit test without TDD?

I am in a project where we do not do TDD, because our bosses and the client are very β€œold” people. Since I cannot do design through TDD, but I feel fear of change, I would like to write unit tests for my own safety. But how will these unit tests be? Do I have to write a test for each method specification to verify that they are doing what they assume? Should I test every new functionality like TDD, but without design? I have a mess in my head.

Thanks in advance.

+4
source share
4 answers

You probably can't hurt anything by doing unit tests - no matter how well they are done - with the exception of one possible side effect, and that is a false assurance.

We tend not to do hardcore TDD, however the unit test coverage range varies from nonexistent to moderate depending on the project and becomes more valuable as the idea settles.

For general pointers, I would say that the following key priorities for you right now:

  • Check what you know to be important.
  • Check what you know how fragile.
  • Record the tests to identify any new errors, and then fix the error by making changes that pass the test
  • Apply TDD, where possible, to any new features.
  • Confirm that you cannot TDD an existing project. By its nature, TDD applies only to a new base, whether it is a new product or a new feature for an outdated product. Do not let this fact depress you.
+6
source

You will find a lot of good advice for your situation in the following book: http://www.amazon.com/Working-Effectively-Legacy- Michael-Feathers / dp / 0131177052

+1
source

Yes TDD is another software development technology that is used for intensive unit testing. Unit testing as a process in itself without TDD. Not to mention that sometimes even TDD cannot be done, but you write tests (think about old systems / testing unverified codes).

But what you should check. Depending on how deep you can get tested (you can), you can start with end-user-oriented functionality by testing system components (i.e. class contracts) to simply ensuring that your code does what you argue in it, this is pretty much the final, finest-grained unit test, which is likely to have a lot.

In general, what to test is a difficult question, I already had to answer several options for this question to give you some tips:

In addition, reading the few votes cast by unit testing may give you some ideas on why you will be useful in testing, whether or not you use TDD.

+1
source

When you say β€œwe don’t do TDD”, do you mean that others do not practice TDD or that your bosses forbid you to practice TDD? If this is the first, then you can practice TDD as much as you want, if you are not trying to get other people to do it. If this is different, then tell your superiors that they are paying you to write the code, as you know, like TDD is part of how you do it.

You can, of course, write tests without practicing TDD. People do this all the time. Use the old adage: "Experience until fear turns into boredom." Write tests for everything that you are afraid may not work correctly.

+1
source

Source: https://habr.com/ru/post/1397278/


All Articles