Test run: Use Windows PowerShell for small test

Source: Internet
Author: User

You can consider Windows PowerShell as a significant upgrade to the old Cmd.exe command shell and related. bat files. Although Windows powershell™ is designed for system management tasks, some of its features also make it perfectly suitable for lightweight test tasks. This month, I will test the Microsoft®.net Framework based on the Windows PowerShell command line and lightweight Windows PowerShell scripts in two ways.

Take a look at the screenshot shown in Figure 1 and Figure 2. Figure 1 shows a Windows PowerShell that performs a specialized interactive test on a. NET DLL module named Mypointlib. Windows PowerShell provides syntax for creating objects and dynamically loading libraries into a running shell process. I will load the test Mypointlib library, instantiate a point object, probe the available methods of the object, invoke the Distance method, and verify the correct result.

Figure 1 Specialized tests using Windows PowerShell on the command line

Figure 2 shows the output of the Windows PowerShell script. Here, you'll see that I'm performing a traditional module test-instantiating the point object of the Mypointlib library, calling the instance and static versions of the Distance method, and comparing the actual results to the expected results to determine the "Pass/fail" (pass/fail) result of the test case.

Figure 2 Traditional module testing with scripting

In this column, I'll start with the class library that I tested, and then introduce the Windows PowerShell command shown in Figure 1. I also pointed out the Windows PowerShell method for interactive testing of. NET based modules. I then explained the resulting script for the output in Figure 2. The download section provides the source code for the test tool and the library that is being tested.

Next I explored how to extrapolate the methods shown in this article to meet your own testing needs, and then discuss the scenarios in which Windows PowerShell is more appropriate than other scenarios, such as the NUnit Unit test framework. I'm sure you'll find that Windows PowerShell is a good addition to your software testing tools.

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.