The Artima Developer Community
Sponsored Link

Java Buzz Forum
Better-factored unit tests w/ naming conventions, reflection

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
Steve Conover

Posts: 37
Nickname: sgcjr
Registered: Feb, 2003

Steve Conover is a professional Java engineer and consultant
Better-factored unit tests w/ naming conventions, reflection Posted: Jun 26, 2003 9:57 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Steve Conover.
Original Post: Better-factored unit tests w/ naming conventions, reflection
Feed Title: Steve Conover's Weblog
Feed URL: http://www.sonic.net/~conover/index.rdf
Feed Description: Mostly java-related.
Latest Java Buzz Posts
Latest Java Buzz Posts by Steve Conover
Latest Posts From Steve Conover's Weblog

Advertisement
From the why-didn't-I-think-of-this-before-now dept: There's usually a point on every project where you move out of your here's-how-we'll-do-persistence phase, where you build your prototyping around one or two entities, to the harder-core implementation phase where you start essentially copying and pasting and renaming to create your 50 entities. Getting better reuse out of the actual entity classes, and whatever your DAO-type functionality is, is a topic for another day (this is where Nanning mixins shine). If you're doing Test-Driven Development, (where possible) you need to write a test in order to give your mainline code permission to exist. Rewriting test code for each entity, that demands it have create, update, delete, etc functionality is tedious and results in a huge set of code that in and of itself has a certain inertia that discourages change. I made an abstract class called EntityTestSupport which extends TestCase, and has a constructor which takes a Class as a parameter. Then I make a test for each entity which extends this superclass, feed in the entity class as the parameter to the superclass constructor, and inside my superclass I run the entity through a bunch of common tests using naming standards and reflection. For entity X, I have XFactory, which has methods newX, getXById, removeX, etc - and inside EntityTestSupport, I have tests that flex each of these operations. This is great from a TDD perspective, because merely extending the superclass and feeding in the name of the next entity I want to create, creates a demand for a new fully-featured entity type. And in the concrete test class you can obviously write tests specific to that entity. Pretty neat....

Read: Better-factored unit tests w/ naming conventions, reflection

Topic: Checkstyle 3.1 released Previous Topic   Next Topic Topic: Checkclipse - looks great

Sponsored Links



Google
  Web Artima.com   

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