The Artima Developer Community
Sponsored Link

Agile Buzz Forum
SUnit Test API Density

0 replies on 1 page.

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 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
SUnit Test API Density Posted: May 12, 2006 3:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: SUnit Test API Density
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Can't find a reference, but urban legend says that the Great Beck said that SUnit was something that should be so simple you could write it on the train (meaning on a commute). The simplicity and versatility of SUnit means there's lots of ways to use it. I don't think there is any one right way to use it. You use it in the way that works best for you. One example of this is whether you choose to associate TestCases 1:1 with classes. Some do religously. Some write great big acceptance tests. Some write a TestCase per unit of functionality (a good example of this one is the AnnouncementTests).

It's fun to introspect on one's TestCases and then imagine how we might abuse the statistics we fetch from some queries. Here's a query similiar to the last post:

| func |
func := [:class | | nonAPICount ratio |
  nonAPICount := (class selectors reject: [:each |
    each = #setUp or: [each = #tearDown or: ['test*' match: each]]]) size.
  ratio := nonAPICount / class selectors size.
  (ratio / 0.1) ceiling * 0.1].
(SUnit.TestCase allSubclasses reject: #isAbstract) groupedBy: func

What's this do for us? First of all it puts the evaluator in a block, so that we can do different things with the function. This is a common thing I'll do when prototyping in workspaces. f(x) is... And then do stuff around however I've defined f(x). The f(x) in this case is to compute how many of TestCase's methods are core API methods. That is, testMethods (and the setUp/tearDown). The last little bit of the block, is a "round up to" expression.

There's no table to show here. What I found was that I have a good many tests at 0.0. And some at 0.1 (66% for the two). And less going up. Which is what I tend to prefer. In the same vein as "any method that won't fit in the code pane is probably to big", I tend to push back against TestCase classes having much more than just tests (and not becoming programs in and of themselves).

Read: SUnit Test API Density

Topic: Exptional Announcements are Exceptional when Announced Previous Topic   Next Topic Topic: Answering the Enterprise Architect

Sponsored Links



Google
  Web Artima.com   

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