I do not write tests. I'm dumb?

I did a little bit of unit testing and TDD, and I never seriously considered such tests to that extent. Of course, I do not work on projects that are ridiculously huge. If all I create is small applications, am I stupid not to write tests?

Change To clarify, when I say "small applications", I mean applications that will not control the lives of people and / or their things. In general, I build things that should make life easier for peoples and make them more effective.

+46
unit-testing tdd
Aug 07 '09 at 22:34
source share
20 answers

Try and find out. How much of your time is debugging now with your small applications? How many errors do users get? How good is your design? Are you satisfied with this? Can other developers work on this, understand this?

Try TDD and see how it works for you. If this helps you come up with happier answers to the above questions, then stick with it.

You are not stupid because you are not doing TDD - but you can be a little tense if you are not even trying to do it.

+72
Aug 07 '09 at 22:38
source share

I know that TDD has gained a lot of hype over the past few years, and I understand that you may have skepticism around software projects that get a lot of attention. However, I can tell you from experience that TDD is not just hype. Before testing the modules, I developed a lot of software, which, as I thought, was “durable” (without errors, excellent performance, etc.). I heard about Unit Testing and decided that I would try it on a "small project", especially since it does not take a lot of time to implement.

To my surprise, I quickly realized the merits of testing. Functions that I thought were 100% perfect would produce strange results. Changing one component may cause another to work with unit test. This was interesting because I realized that my code only worked when I entered what I (as a developer) expected input from the user, and not what they could do in the production version of the application.

This surprise led me to a number of conclusions about TDD (besides the typical advantages):

  • TDD allows you to test each component at any stage of the application (you can configure the environment for each test). This ensures that the functionality of the component remains the same throughout the application.
  • TDD usually encourages good design. Typically, you cannot test individual units of an application without compromising the system. Interruption of the application in the tested parts (especially when using the inversion of the control template) forces the developer to write better code.
  • TDD enhances developer and end-user confidence in the system. Will you trust a system that would be inappropriate? Or one that is thoroughly tested?

There are many other benefits to TDD. There are also some disadvantages (time for implementation, implementation of tests inappropriately). I can say that practicing TDD will usually help you improve your development skills.

Finally, I know that you mentioned that your projects are usually small, so my question to you is why not check it out? It does not take long to implement. If you work in .NET and Java, the main IDE has functions to optimize the testing process. I also bet that other languages ​​have similar features in their IDEs.

+30
Aug 07 '09 at 22:58
source share

The great advantage of tests from the programmer’s point of view is not so much in proving that your application works (in fact, unit tests do not actually do this), but in the fact that you can make radical changes to the application. With the help of tests, you can change anything / everything and determine that the code does the same before and after the change.

+20
Aug 07 '09 at 22:57
source share

In my experience, tests are documentation. If you ever have to explain how something works, you point developers to tests. Comments are generally not as valuable as tests.

+17
Aug 07 '09 at 22:45
source share

My personal opinion is that you sacrifice quality and long-term effectiveness , do not write tests. I'm not sure this is stupid. Without writing tests for your code, you must rely on other methods to ensure proper operation and not break working code when making changes. The only ways I can think of to compensate for the lack of writing tests should be incredibly smart (and observant) so that you never make mistakes (or catch them before they become problems), or to check everything in the debugger. I'm not smart / observant enough for the former and I don't have enough time for the latter, so I write tests.

+9
Aug 07 '09 at 22:43
source share

It's not about being stupid or smart, about quality assurance and supported code. If you do not want to do this, then do not write tests.

I write tests for everything because 99% of the time the application will change, and the tests ensure that the application does not break when changes are made.

+7
Aug 07 '09 at 22:37
source share

What tests do you do? How often do you check when you make changes? Does testing testing test the number of tests tested?

It’s much more interesting for me to record repeated tests than to do them manually, over and over.

In general, for me, obviously, an important thing is that one test is often enough to catch errors.

The unexpected thing for me was that when I started writing explicit unit tests, I think my code got better. Just thinking about which tests are needed, I thought more carefully about the cases of ender.

The big trick is deciding where to focus your testing efforts. UI's? I check it manually. Gnarly Computing Engines - Write a lot of test cases.

+7
Aug 07 '09 at 22:39
source share

If no one touches the code again, you do not need to write tests for it, since one of the advantages of testing is maintainability (is this true? = P).

And if everything you do in your work is just that, you don’t even have to deal with TDD or best practices at all. But maybe you should consider changing your work if you want to learn the best development methods.

In such a job, your boss will not take you so long to write tests and coding.

+6
Aug 07 '09 at 22:44
source share

Tests are one way to ensure quality and supported code. However, poorly written tests do not help anyone, and can often provide a false sense of security that makes error binding difficult.

EDIT:

High quality, supported code starts with good design - the project must consider what may go wrong before writing code, and write about it. I’m not saying that the tests are bad, I’m just saying that you can’t say that it’s all the time because it’s what is “right” and then think that you understand it. Like any other “rule”, it makes sense if you understand why you are doing it enough to do it well.

+5
Aug 07 '09 at 22:39
source share

As I mentioned in another discussion, I was a supporter of TDD until I tried it in a real life project - no more.

However, I find automated tests very useful, especially. acceptance tests, integration tests and regression tests. Just don’t think that the development process should be centered around the tests. In addition, I did not see much benefit from unit tests - maybe because I mainly use statically typed languages.

+4
Aug 21 '09 at 17:32
source share

I would try. I decided to try it on a side project. During the first few days, I already hid my skin on several occasions when my code changed, causing the “side effects” that my unit tests caught.

I realized that I actually have less time debugging and “checking” my code by running it and manually checking it. Now in this project I can change the code and run unit tests and know this well, instead of launching the application and entering into my set of values, each time I check everything visually every time I make changes.

+3
Aug 07 '09 at 22:42
source share

Intelligent people do stupid things all the time. You do not need to use full-sized TDD, but do not write automated tests at all, when everyone believes that the best practice is, of course, stupid behavior.

Personally, I would say that the only excuse for not writing tests is that quality matters much less than getting a quick result (no matter how half-open it is) or when the code will not remain long. Throwaway scripts, research prototypes, a new feature with a deadline tomorrow set by an impatient but error-resistant client. That kind of thing.

For everything else, automatic tests mean you deliver higher quality with less overall work.

+3
Aug 07 '09 at 23:06
source share

My experience:

  • Wrote 75,000 lines, mission critical applications.
  • From the day we pushed this program to live production, it has done what it means with reliable reliability on the breed.

Disclaimer: I programmed since childhood, so I am well versed in my work, but even I was surprised by the dramatic effect of several simple testing rules so that the application runs as reliably as the top end of Mercedes.

Testing form that worked for me:

  • I did not do what some practitioners recommended, namely, "test first and then code." Rather, I took an approach to integrating as many tests as possible into the project, as I thought, before or after the actual code. For some methods, it was easier to write a method first, then tests. For other methods, it was easier to write tests first, then the method.
  • I did not use the unit testing framework, but I integrated the tests into the program itself, as described in the remaining paragraphs. The only base I used was a third-party logging structure for any warnings and errors generated. I will not call the commercial that I used to keep this article neutral, and any free or commercial journal structure will do. I recommend any logging structure that allows you to view the logbook and then filter by some criteria, as it is very useful when viewing large logs for any suspicious activity.
  • Class level testing was used: each class had a method that checked all other methods in the class. Some methods had a "sister" method, which was responsible for running tests using the specified method.
  • Application -level testing was used: a lot of unit tests were written to pump real data into the program, and then check that the returned data was as expected (usually it was just a border check).
  • Linear testing used : every time I knew the expected range of values ​​inside a variable or array, I would write a silent warning if the data fell outside this range. In other words, I had unit testing integrated into the code structure itself. These tests could be disabled in Release mode, but I found that it did not greatly affect the speed of the final application, so I just left them.

From the whole test that I added, I found that linear level testing had the greatest positive impact on the reliability of the application as a whole. Surprisingly, a simple rule, such as “log the silent warning message, if the contents of the variable is not what you expect,” can have such a profound effect on the reliability of the application as a whole.

The best part about this approach is that it actually shortened the development cycle. Of course, there were many errors and warnings recorded at an early stage, but once they were fixed, the end result was surprisingly reliable. This approach made the program more robust for change and refactoring. I ignored the number of times that I changed what, in my opinion, was insignificant, which caused a warning that allowed me to correct a mistake that could lead it into production. Almost eliminated the usual phase of post-production costs of finding hard-to-reach errors. This was extremely important since it was a critical application that put at stake if it went wrong.

The testing form I used is not a silver bullet, but it will make your life easier (and the life of your bosses).

The bottom line is that the only time I didn't use testing was if I were a kind of masochist working for my worst enemy, and I wanted to make my life a hell.

+3
May 05 '13 at 14:00
source share

Kent Beck asked a similar question on his last blog post , but he states that he only refuses to check anything, to know if there will ever be long-term software (maintainability, etc.), and the test is very difficult to write.

+1
Aug 07 '09 at 23:03
source share

Having read your changes well, I would say that your goals are to make life easier for people, which requires knowing their needs and satisfying their needs. They evolve, and like them, you need to change your code. TDD really shines, in my opinion, during these updates ... but you should start with it.

It also helps when other developers look at your code later and cannot understand how their change broke it, or if they are trying to fix something that you accidentally broke before leaving this place.

Keep in mind that my TDD experience is limited, because it’s hard for me to convince anyone to start a project using it ... but every project I have ever done that used TDD was easier to maintain because of this.

+1
Aug 21 '09 at 17:03
source share

Not all code can be checked by the module, and this is not suitable for any situation. Therefore, choose something non-interface, controlled as a starter, for example, something financial or settlement. Try it and you can love it.

+1
Mar 31 '10 at 11:01
source share

TDD and unit testing in general will help you if you need to "support" your code. If you need to add a function, for example, or if you need to have a sufficiently small number of defects, and therefore you need to fix them. If you never maintain code, then unit testing will only interfere with performance. This can be the case for small scripts and applications where all the necessary (manual) testing is required.

Before considering adopting a policy, always consider what value it adds to the business. At the same time, I consider this an extremely rare case in the field of programming, where unit testing is an obstacle rather than a benefit.

+1
May 14 '13 at 18:07
source share

I will not repeat all the benefits of TDD listed here and in many other resources. Nevertheless, I can say for myself that as soon as you get settled with a test platform for your language , the time taken to write a test is about the same as when manually testing the code . Thus, I prefer to run a test that stays there, and always check the correctness of the code, rather than manually check it every time something changes, even if it never changes.

Sometimes I see people who make the main method and manually test their code by typing the results and looking at them. Dude, just do the test - this is the same amount of code. :)

In addition, TDD allows you to write more modular software that can be tested, and IOC - friendly, which provides not only testability, but also the customization and flexibility of your application.

+1
May 14 '13 at 18:28
source share

The larger the project, the more important it is to write tests. If only you, working on a small project, it’s usually good to write tests. If this is you and the team working on a medium to large-sized project, thorough and meaningful testing is necessary if you want to provide high-quality, supported code.

0
Aug 07 '09 at 22:44
source share

While one of the main benefits of TDD is that you maintain the integrity of your code by verifying that it works, this is not the only advantage. Another important advantage of TDD, if done correctly, is that you isolate some of the functionality and develop against it. When you write your tests before your code, you force yourself to consider what exactly your method should do based on the expected result.

When you perform this approach from scratch, you write your tests for your foundation, and as you move further into the application, you will see that you can refract and refine the code. When you apply these changes, the test itself plays its vital role and informs you that you have touched on something else in the application.

The use of tests for software development requires a significant change in the thinking process. Even now, when I can’t complete the test development, it’s hard for me to go back and write tests. This becomes a tedious task that I would rather not do. However, when I write them first, it becomes a critical design process. I found that it is much more difficult to do when entering a project that is ongoing.

Edit: There is nothing like the satisfaction you get when you write a method that keeps throwing red, just to have the moment “ha ha” and watch the bubble turn green, or the feeling of relief that you get when you do a little a change that you think will not affect the rest of your application, only to see the red lights go out.

0
Aug 21 '09 at 17:15
source share



All Articles