Writing unit tests for code with EditOperation

336
1
12-22-2021 03:23 AM
GKmieliauskas
Esri Regular Contributor

Hi,

I try to write regression tests for my ArcGIS Pro code. Some code contains EditOperation object functionality.

My code for ArcGIS Pro add-in works fine, but when I run the same code with same input data from unit test EditOperation ExecuteAsync return false.

Is it impossible to write test for EditOperation or there is some magic to do that?

0 Kudos
1 Reply
BILALRasheed
New Contributor

Unit Tests, How to Write Testable Code and Why it Matters
In this article, I will show that unit testing itself is quite easy; the real problems that complicate unit testing, and introduce expensive complexity, are a result of poorly-designed, untestable code. We will discuss what makes code hard to test, which anti-patterns and bad practices we should avoid improving testability, and what other benefits we can achieve by writing testable code. We will see that writing testable code is not just about making testing less troublesome, but about making the code itself more robust, and easier to maintain.

Unit testing is an essential instrument in the toolbox of any serious software developer. However, it can sometimes be quite difficult to write a good unit test for a particular piece of code. Having difficulty testing their own or someone else’s code, developers often  think that their struggles are caused by a lack of some fundamental testing knowledge or secret unit testing techniques.

In this unit testing tutorial, I intend to demonstrate that unit tests are quite easy; the real problems that complicate unit testing, and introduce expensive complexity, are a result of poorly-designed, untestable code. We will discuss what makes code hard to test, which anti-patterns and bad practices we should avoid improving testability, and what other benefits we can achieve by writing testable code. We will see that writing unit tests and generating testable code is not just about making testing less troublesome, but about making the code itself more robust, and easier to maintain.

0 Kudos