Windows Phone Unit Test Environment Setup

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.