Developer's Corner Thick UI Simply pass needed data into your custom classes from your unit test fixtures and validate what you have control over. For stand-alone ArcGIS Engine and ArcGIS Server applications, the developer typically controls all the code so a custom app. will typically already contain code to create an instance of everything a unit test needs. While there is no IApplication lurking in the background to muddy the waters, validation of custom functions is still complex because we still need a way to validate a geometry or a feature class. When developing applications for ArcGIS Server, custom code should be kept out of code-behind files and *.asmx files. This allows migration of custom components to the server object container (SOC) and will increase ease of unit testing. Unit Testing Geometry Operations: A Test Case for ArcUnit No matter how much we design for unit testing, we are still faced with the problems of how to collect the needed objects/data to pass Thin UI Code directly in event handlers Very dif cult to test—can't simply call functions UI Most code is in business objects UI just wires BO together UI BO Test Fixture DAL Figure 2: Proper abstraction of business logic away from UI and event handlers to facilitate testing DAL in to a test method (feature class, geometry) and how to validate the results of the test (e.g., check that a given geometry result is correct). ArcUnit, a community-based open source project, provides tools and utilities to address this need. Currently hosted on Assembla at http://svn2.assembla.com/svn/arcdeveloper/ TestingUtilities, the ArcUnit effort consists of a series of utility classes and tools designed and implemented to assist the developer in manipulating and validating data when unit testing ArcObjects code. These tools can be freely downloaded by developers who are encouraged to use the tools provided and contribute new functionality for the benefit of the developer community. The ArcUnit code base has been started with tools and utility classes to unit test custom geometry editing functions. To date, the effort has focused on how to simulate sketches, store and retrieve geometries, and create tests against independent datasets not tied to a specific instance of a geodatabase. A custom ArcGIS Editor extension and toolbar are included in the source code, as well as utilities for serializing and deserializing ArcObjects and classes to simulate commonly Continued on page 40 "Left" XML File "Right" XML File Figure 3: Using ArcUnit custom editing toolbar to serialize geometries for use in unit tests www.esri.com ArcUser Winter 2010 39