Support unit testing in ArcGIS Pro and ArcGIS Runtime .NET SDKs

11-11-2015 11:20 AM
Status: Open
Labels (1)
New Contributor II
In ArcObjects .NET, everything has interfaces and can be mocked with modern lightweight mocking frameworks such as NSubstitute or FakeItEasy, allowing the developer to write real unit tests in which the business logic can be tested in isolation (independent of any access to real ArcObjects resources). In the ArcGIS Pro SDK 1.1 and ArcGIS Runtime SDK .NET 10.2.6, this is practically impossible for several reasons:
  • There are almost no interfaces.
  • Many classes are sealed and/or have no virtual members and therefore cannot be faked (mocked).
  • There are many static method calls.
With both SDKs, Esri wants to support the MVVM pattern in which the business logic resides in the view models and the classes that are spawned from them. One of the benefits of the MVVM pattern is that the business logic can be tested in isolation, independent of the UI. However, as long as the dependencies of Esri's SDKs cannot be faked, for the TDD community they will be useless.
We would like Esri to provide support for faking (mocking) their SDK objects so that developers can write tests that comply with the FIRST principles and test only their business logic.
Use Shims...

They can mock static / non-virtual methods.

I know, but Shims are part of MS Fakes, which is available only with Visual Studio Enterprise Edition. The ArcGIS SDKs support all editions of Visual Studio.

Sounds to me a biased answer. It limits the posibilities


Today, at the end of 2018, with the ArcGIS pro SDK in version 2.2, and I am not able to generate unit tests, not even mention apply TDD, because the SDK does not have Interfaces and most of the classes are sealed.


Having interfaces would make testing so much easier. The class library is great, just lacks the interfaces which is the base for being able to write independend unittests. Currently it is hard to convince people to write unittests, with so many obstacles on the path.