Microsoft launched a Silverlight unit test framework in. This framework was launched at the same time as Silverlight controls in mix 08, microsoft engineer Jeff Wilcox has been involved in maintaining the unit test framework.
Scott Gu's introduction to this framework
Video introduction provided by Jeff Wilcox
TheSource codeIt is already included in Silverlight controls. For more information, see the latest binary files and related tutorials and links on the msdn code homepage of this framework.
The following describes how to use the unit test framework.
First, download the latest single-test framework DLL from here.
Then we open vs2008 to create a Silverlight application to run the unit test. We name this project unittest.
Decompress the downloaded framework DLL to the project directory (I created a new ref directory), right-click references, and add the two extracted DLL files, Microsoft. silverlight. testing. DLL and Microsoft. visual Studio. qualitytools. unittesting. silverlight. DLL.
Because the framework can generate a test page, we put the page in the project. XAML and page. XAML. delete CS, and then open the app. XAML. CS, add to Microsoft. silverlight. testing Reference, and modify rootvisual to unittestsystem. createtestpage ();
View plaincopy to clipboardprint?
- # Using Microsoft. Silverlight. testing;
# Using Microsoft. Silverlight. testing;
View plaincopy to clipboardprint?
- Private VoidApplication_startup (ObjectSender, startupeventargs E)
- {
- This. Rootvisual = unittestsystem. createtestpage ();
- }
Private void application_startup (Object sender, startupeventargs e) {This. rootvisual = unittestsystem. createtestpage ();}
Then we add a class in the project, reference Microsoft. visualstudio. testtools. unittesting in the class, and add a testmethod,CodeAs follows:
View plaincopy to clipboardprint?
-
- UsingMicrosoft. visualstudio. testtools. unittesting;
-
-
- NamespaceUnittest
-
- {
-
- [Testclass]
-
- Public ClassTestgame
-
- {
- [Testmethod]
-
- Public VoidTestdispose ()
-
- {
-
- Assert. istrue (True);
-
- }
-
- }
-
- }
Using Microsoft. visualstudio. testtools. unittesting; namespace unittest {[testclass] public class testgame {[testmethod] public void testdispose () {assert. istrue (true );}}}
Press F5 to run the project and check the output result. Is it very convenient?
Of course, you can also use this framework to perform the Silverlight UI unit test. For details, refer to Jeff's article.Article.
Reprinted please indicate from the Chinese blog of et Wali Silverlight Technology