Unit Testing and ArcGIS Server

Just a quick note on using NUnit for testing classes working with ArcGIS Server. I had setup my testfixture so that it would get a server context in the <SetUp()> sub, and release it in the <TextFixtureTearDown()> sub. This is generally good form – get an expensive resource one, and use it for all the tests…

<SetUp()> _
Public Sub Init()
‘Set up the connection to the GIS Server
    _SC = ServerUtil.GetMapServerContext(_AGSHostName, _AGSContextName)
End Sub

<TestFixtureTearDown()> _
Public Sub TearDown()
    _SC.ReleaseContext()
End Sub

And this works fine if you only run one test at a time, or if you only have one test in your test harness class. However, if you want to run a bunch of tests, you need to release the context at the end of each test, and thus also create it at the beginning. Simple enough, but somewhat confusing to see that you suddenly have 4 instances running when you only thought you had one.

Media_httpblogdavebou_gpopx
Advertisement
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s