The effect of unit test on engineering quality is not explained in detail, this article only discusses how to build test project under WP development environment.
History
From the WP7 era, the official did not support the UnitTest project, so the need to use wptoolkittest this project to implement unit testing,
To refer to the article on the Nokia Develop: address
This way to build the test environment, the test needs to be in the simulator or the real machine click on the Start Test button to test, so the way I think is not friendly
By the time the Vs2012update2 was released, the official unit tests were finally joined, and it was possible to rely on VS's test management for more convenient management of test cases:
Build steps
Refer to Tutorials in MSDN: Address
This tutorial has clearly explained how to create a Windows Phone unit Test project, but there are still a few things that are not mentioned in the tutorial, and here we come to one by one to solve this problem:
1, async/await
Came to the WP8 era, with the addition of the two keywords await and async, obviously these two keywords are obvious to the improvement of the program structure, so in the project we will also encapsulate such a style of interface, so if there is such a style of code in the test code how to test it?
Take a look at the example:
We look at the above interface, the method in the interface is to get the user information by token so we should write the corresponding test code when we test it:
A key point is to add async and task modifiers to the test function so that you can test the
2, Mock the Library what to do
When it comes to unit testing, the concept of mocks, which is still not detailed to illustrate why mocks and how-to mocks, can be used to search for learning by keyword.
During the author's use, it was found that most of the mainstream mock libraries did not support Windows Phone when adding mock libraries in nuget way:
such as the MOQ above the library, which is very frustrating ...