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

2058
4
11-11-2015 11:20 AM
Status: Open
FridjofSchmidt1
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.
4 Comments
JohnJones
Use Shims...

https://msdn.microsoft.com/en-us/library/hh549175(v=vs.120).aspx

They can mock static / non-virtual methods.

 
FridjofSchmidt1
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.
Cristian_Galindo

Sounds to me a biased answer. It limits the posibilities

Cristian_Galindo

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.