Unit testing WPF legacy application

The product I worked on has been under development for the past six years. It began as a general portal for entering data into the insanely complex part of WPF / part of the old application. The system has been developed over the years without a single Unit test. Now a question has been raised for a comprehensive unit testing framework. I was recently hired to work on this product, and I was commissioned to put the "Testing" in order. Since the team that has been working on the product over the past six years has accepted Agile, there is no documentation on the business rules or any project documents in the project.

I am trying to write unit tests for some modules. But I'm not sure what to do Mock, how to set up test equipment and, in the end, what to test, since a casual look at the methods does not reveal its intentions. In addition, it occurred to me that the code was not designed with a specific methodology in mind.

Given the situation, I was wondering if the good Stackoverflow people can provide me with some tips on how to save this situation. I heard about the book “Working with Legacy Code,” which can say something about this general situation, but I was thinking about getting some pointers from people faced with similar situations in the technology stack (C #, VB, C + +, NET 3.5, WCF, SQL Server 2005).

+3
source share
2 answers

In my opinion, the best way is to start by “stabilizing” the current code functionality with integration tests. Try creating tests that have a starting point that is unlikely to change later. Using integration tests, you can be sure that refactoring, which will be released later for unit tests, does not violate anything.

The next step is the unit test code. If you can reorganize the code, you can start dividing the logic into classes (for example, additional logic at the level of visibility) and add unit tests to them. Using this process, you will also better know the product code.

It is highly recommended that you read “Working with Obsolete Code,” many of the problems you encounter already have solutions :)

, , . , , White framework . , : Typemock Isolator ( - Typemock), . , , :)

+4

@sc_ray: , , , , , , MVVM .
, , if, , .
, , , , , WPF. - , ...

+3

Source: https://habr.com/ru/post/1739614/


All Articles