Unit testing ArcGIS Runtime SDK for .NET

6553
12
02-11-2015 05:24 AM
JuhoVainio
Occasional Contributor

As far as I know, the current ArcGIS Runtime SDK for .NET cannot be unit tested because we simply cannot create new instances from the classes and thus cannot mock any return values from queries. The older ArcObjects library was easier to mock, because every class also had an interface assigned to it.

Currently this is a bit of a problem because we cannot create unit tests for ANY functionality that uses any of the ESRI's classes (or they become integration tests).

Is ESRI going to upgrade the SDK so that unit testing might be possible in the near future?

Tags (2)
0 Kudos
12 Replies
FridjofSchmidt
Occasional Contributor

Typemock Isolator is great, I know... and there are other commercial frameworks that use the Profiling APIs, such as JustMock and MS Fakes, with similar abilities that are very helpful, especially for legacy code. I was just hoping NOT to need them and to stay with my favourite, free and easy-to-use NSubstitute. In my opinion, when writing new software from scratch, creating fakes with dynamic proxies (like NSub does) should be perfectly sufficient. I particularly like that this approach forces you to think about design goals more seriously, leading to cleaner code.

0 Kudos
BrianLocke
Occasional Contributor II

First off well done with .net.  I am little curious if you guys could get a unit test example perhaps using nUnit. read through here a couple of times having a hard time visualizing this one.

0 Kudos
FridjofSchmidt
Occasional Contributor

Juho,

There is now an idea at ideas.arcgis.com: Support unit testing in ArcGIS Pro and ArcGIS Runtime .NET SDKs​. If this seems important to you, please promote the idea.

I don't consider this question answered. Apparently, Esri uses MS Fakes internally for writing their unit test, i.e., they can isolate their code from dependencies by using Shims. However, MS Fakes is only available for the Enterprise edition of Visual Studio. Both the ArcGIS Runtime SDK .NET and the ArcGIS Pro SDK support all editions of Visual Studio.