The Artima Developer Community
Sponsored Link

Weblogs Forum
A Set of Unit Testing Rules

50 replies on 51 pages. Most recent reply: Jan 21, 2011 2:19 AM by Steve Merrick

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 50 replies on 51 pages [ « | 1 ... 13 14 15 16 17 18 19 20 21 ... 51  | » ]
Curt Sampson

Posts: 21
Nickname: cjs
Registered: Mar, 2004

Who cares if it's a "unit test"? Posted: Sep 12, 2005 2:42 AM
Reply to this message Reply
Advertisement
I certainly don't. I have several different groups of tests, some of which run faster than others, and that's what work with. For example, at my day job, some of my current options are:

1. Database reload and database functional tests (2 seconds)
2. Run all ruby unit tests, without a database reload (2 seconds)
3. Run functional test of a program written in ruby, without database reload (1-2 seconds)
4. Database reload, run ruby unit tests, another reload, run all functional tests of programs written in ruby (7-10 seconds)
5. No database reload, start web server, run test cases from one class in the web test case suite (5 seconds, for the one I just tried)
6. Database reload, start web server, run all web test cases (30 seconds or so)
7. Everything (45-60 seconds)

Now it's a small system, but I've also done a lot of optimization of how I test over the years. (Switching from Java and HttpUnit to Ruby and test/httpweb for the web tests made them about an order of magnitude faster, as well as easier to write.)

I move stuff around between different kinds of testing as well, based on speed and convenience. (Some of my servlets are tested with unit tests in order to reduce the number of (slower) web tests, for example.)

The comment about "if it accesses a database, it's not a unit test" really irked me. Databases have code in them too, and that code should be tested just as you test any other code. I regularly migrate code back and for between, say, Ruby and SQL stored procedures, based on what's easy, what kind of security I need, and so on. In fact, I'll go so far as to say that your database schema *is* code, and should be treated as a first class citizen along with all of the rest of your code. (BTW, there's a bit of my unit test framework for PostgreSQL available in the pgtools project on SourceForge. Bug me and I'll update it.)

Flat View: This topic has 50 replies on 51 pages [ « | 13  14  15  16  17  18  19  20  21 | » ]
Topic: Computer About to Play Jeopardy Previous Topic   Next Topic Topic: The Search for Requirements

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use