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.