Use Windows Mobile test framework for automated testing of Windows Mobile programs-(2) Test Tool

Source: Internet
Author: User


In the previous section, we briefly introduced the Windows Mobile test framework in the wm6 SDK. You may have a rough impression on Windows Mobile test framework, but you still have some questions about how to use it. I am sorry for this because I am busy and have no time to update this series. Today, we will use this Windows Mobile test framework for a small test to see how it runs. Let everyone have a perceptual knowledge of it.

I. Preparations

1. Open tool> device simulator manager in the menu of Visual Studio 2005. Open a professional Simulator for Windows Mobile 6. Connect the simulator to the computer through ActiveSync (wmdc for Vista.

2. Unzip Windows Mobile test to a directory. Double-clickCommandwindowsShortcut. A Command Prompt window pops up. Enter "set" in the window and press Enter. The "path" parameter adds the bin directory path under Windows Mobile test framework. And the Variable _ wmtfroot is added.

3. Enter"SetupdeviceThen press Enter. The system automatically copies and installs necessary files to the device. (Setupdevice is a batch file, which can be found in the bin directory)

4. On the device simulator, you will findProgram". There is a test directory under the root directory of the device, which contains the files just copied. It contains calview. You can open calview, which is a small program used to view calendar information in poutlook.

5. Use ActiveSync or wmdc to% ProgramFiles % \ Windows Mobile 6 SDK \ tools \ SECURITY \ SDK Development Certificates \ certs. CabCopy it to the simulator and install it.

6. manually create an entry in the calendar of the simulator for later use.

2. Understand the test project

1. Open_ WmtfrootUnderCalviewsampleIn this directory, you will find that there are three sub-directories, which are "regionactionlayer", "arealibrary", and "tests ". They are the "uial", "arealibrary", and "tests" layers described in the previous section. As for datk and MTK, they are all provided by Microsoft. You can_ WmtfrootUnderDevicefilesDirectory (Microsoft. WindowsCE. datk. dll and Microsoft. mobiledevices. ityitytoolkit. dll ).

2. the Code at the tests layer references the code at the area library layer. The code at the area library layer references the code at the uial layer. Therefore, we first use vs2005 to open the project under the javasactionlayer. The extract actionlayer of calview has two versions for PPC and smartphone respectively. First, open the solution under the pocketpc directory. You will find that there are two projects in this solution, one is " Microsoft. mobiledevices. specified actionlayer. calview. pocketpc , and the other is tuxnet ". The former is the uial Layer Code of the PPC program of calview. The latter is actually an empty project, and its purpose is only to deploy the files contained in it to the device. Open the properties of the uial layer project, and the devices Option page. Select "use this certificate to sign the project output" in "Authenticode signature ". Click "select certificate..." and select " test use only-sample privileged root for Windows Mobile SDK ". This is a privileged certificate used for testing. If this certificate is not displayed, click "manage certificate" and import " % ProgramFiles % \ Windows Mobile 6 SDK \ tools \ SECURITY \ SDK Development Certificates \ sampleprivdeveloper. pfx ". Open the select certificate page again and you will see it. It is designed to test the signature for your uial-layer code, so as to facilitate access to some privileged functions, so as to avoid the pop-up prompts during the running process, and then compile the solution. Then close the solution, and also process and compile the uial layer solution of smartphone and the area library layer solution.

3. The solution for enabling tests is also processed. Then, set"Debugging"Option page,"Start Operation"Is"Start external programAnd set the value to \ test \ tuxnet.exe ".


3. Run the test program


1. Press F5 to run the solution. Select the simulator you have started.

2. You will find that the system automatically opens and runs the calview program in the simulator. Then, the "copy" menu item is called to copy a calendar project. Finally, exit the program.

3. Open the \ test directory from the simulator and you will findResults. LogFile, copy it from the simulator to the PC end, open it in notepad, It is the running record just now, the content is relatively long, I extract several parts of it as follows:

........................................ ........................

<Testcase id = "0">
* ** Test name: Microsoft. mobiledevices. Tests. calview. calviewtests. calviewbvt
* ** Test ID: 0
Repro:-assembly Microsoft. mobiledevices. Tests. calview. dll-suites calviewtests-Tests calviewbvt
Begin step: calviewbvt
[1] launchapplication (calview, finder): attempting to launch from Start Menu
[1] launchfromstartmenu (calview, windowfinder, false): Opening Start Menu
[1] openstartmenu (): clicking on Start Menu to open it
[1] clickstartmenu (): clicking on Start Menu at (2, 2)
[1] clickstartmenu (): Start Menu successfully opened
[1] launchfromstartmenu (calview, windowfinder, false): Getting list of Start Menu items
[1] launchfromstartmenu (calview, windowfinder, false): item found-clicking on index 9
[1] countbefore = 1
[1] countafter = 2
[1] Verification = pass: Count after is one greater
[1] clickok (): clicking on task bar at (230, 10)
End step: calviewbvt
Verification = pass: calviewbvt
* ** Result: passed

........................................ ........................


* ** Suite Summary
* ** Results
* ** Passed: 1
* ** Skipped: 0
* ** Failed: 0
* ** Aborted: 0
* ** Total: 1
........................................ ........................

4. the first part marked in the above log is the running record of the test case we just ran. The last part is the overall running situation. This operation has a total of 1 case, the result is pass.

5. The name of this case is Microsoft. mobiledevices. Tests. calview. calviewtests. calviewbvt.Calviewtests. CSYou can find the following code, which is the case:

         ///     <Summary>         ///  Add a description of the steps this test executes.          ///  Eg:          ///  1) Open contact app          ///  2) create a contact          ///  3) Verify contact appeats in main List View          ///  4) close contacts app          ///    </Summary>          ///     <Returns>  Log. logresult. Pass on success  </Returns> [ Testcaseattribute ( "BVT" , Type = Testtype . BVT)] Public Log. Logresult Calviewbvt (){// Open the application              Calviewarealib . General. launchapp (); // Store and log the beginning count              Int Countbefore = Calviewarealib . Maindialog. getitemcount (); utils. Globallogger . Addcomment ( "Countbefore = {0 }" , Countbefore. tostring ()); // Select and copy one of the items              Calviewarealib . Maindialog. selectitem ( 0 ); Calviewarealib . Maindialog. copyselecteditem (); // Store and log the count after copy              Int Countafter = Calviewarealib . Maindialog. getitemcount (); utils. Globallogger . Addcomment ( "Countafter = {0 }" , Countafter. tostring ()); // Log a result based on the conditional that countafter is one greater than countbefore Utils. Globallogresultmanager . Results. Add ("Count after is one greater" , (Countafter = (countbefore + 1 ))); // Close the app to clean up              Calviewarealib . General. closeapp (); // Results manager kept track of the result for you, return its summary              Return Utils. Globallogresultmanager . Results. Summary ;}

From the step of case, we can see/guess that it successively opens the calview program, then selects the first entry, and then copies one. Then check whether the number of entries has been added. Close the program and output the result. Here, you can use uail or arealibrary code to view the specific meaning of the Code, which will be further introduced in my blog later.

Iv. Summary

From the above demonstration, we can easily simulate users to operate our programs and perform verification through our code. Good, right?

Now, let's introduce it here. In the next section, we will introduce the structure of tests-Layer Code and its operating mechanism.

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