Upload
manikandan
View
1.121
Download
2
Tags:
Embed Size (px)
DESCRIPTION
A PDF doc. frm various sources, explaining abt the use of powershell, an extension to DOS command in the field of software testing
Citation preview
1
Introduction 1
Features 4
Real World Examples 5
For Testers 8
Message for Testers 10
2
Introduction (As commented by the author in PowerShell Pro…)
PowerShell is a new command shell from Microsoft and yes it is a command prompt and
scripting environment, it can even be both at the same time.
For a systems administrator, the benefits in learning PowerShell are mainly pertaining to Active
Directory domains are becoming larger and more complex. For those administrators that are still
chained to GUI tools and the Microsoft Management Console, PowerShell will set you free!!!
Additional Features to MS-DOS Command:
• Variables, Constants, Arrays, and Hash Tables.
• Using Conditional Logic. • Processing data with Loops.
• Modular Scripting Using Functions.
• Scripting using WMI Objects (Computers, Printers, Etc…).
• Scripting using ADSI Objects (Active Directory Management
Concepts:
Object Based Not Command Based – Output can be piped into another input
Commands are customizable – Create own commands, based on aliases
Command Based and Scripting Environment – MS DOS – command and VB Script – runs
Windows Server Host for executing scripts and not MS DOS runs the command. Same applies
for Windows Batch File
3
4
CAFFEINATED ODOR WEBSITE
Features :
Guessing: In powershell, the verb-noun pattern is strictly enforced and the names are
always consistent so that I can write Get-Command *service and be assured that I will
get all the cmdLets related to services and then figure out what they do through the verb
part of their name.
Built-In Help -If you're not sure what a cmdLet does, then use the Get-Help cmdLet to see
the documentation
Trusting Operations -Are you afraid to execute a script because you're not sure what it will
do? Try the -whatif parameter that is ubiquitous to all commands. For example, del
C:\f*.txt -whatif will just tell you which files would have been deleted rather th
an actually deleting them.
Get-Member- add| Get-member to the end of the command and I can see what additional
methods I have to work with or what properties I can perform filtering and assorting on
5
6
7
A simple script for beginners
8
Powershell for Testers:
A dedicated website of use of PowerShell for Testing: http://testfirst.spaces.live.com/blog/
Project CodePlex by the blogger of previous site; Adam Geras :
http://www.codeplex.com/psexpect
Project Description
A PowerShell library for automating tests. You can use this library to test your scripts, but it is really designed to
test things external to PowerShell: your Active Directory configuration, your SharePoint installation, etc.
This project was initially released for PowerShell v1.0 and has
since been revised so that it works for PowerShell v2.0 (CTP
and above) as well. I've not run the full suite of tests on all
OS/version combinations though, so please log an issue if
you find something wonky.
I built this so that it would be easier to employ PowerShell as a means of automating tests. I believe the
language has features that fundamentally make it a wise choice for automating tests, in particular, when the
targets of the tests happens to publish cmdlets. So while you can use it to test your scripts, it really is intended
to provide you with the means of writing tests to support the work that you are already doing, whether that is
writing scripts, configuring commercial-off-the-shelf products, or developing an application.
Note: The decision not to use cmdlets at all in this solution was to avoid the need to install anything on the
machines running the target of the tests. This is also why relying on an existing .NET test framework (such as
NUnit) wasn't considered the optimal solution.
Regards,
A.
“I built this so that it would be easier to
employ PowerShell as a means of
automating tests.”
Scripts of .net
modules works with
powershell
9
10 quick reasons to come up for testing with PowerShell by James Brundage – MSDN
PowerShell Team – Microsoft Functional Tester (MSFT) (Source: PowerShell Blog)
1. Being able to run command line programs easier within PowerShell
2. Dynamically generating code or test data for a test case (fuzzing or data-driven testing get
a lot easier with this)
3. Being able to access COM easier within PowerShell
4. Being able to embed PowerShell in C# (so you can avoid writing a framework and just
embed PowerShell in your infrastructure)
5. Being able to use weakly typed variables within PowerShell 6. Being able to test APIs on the command line, so you test manually and then automate
7. Getting a history of commands, to take what you've explored and turn it into a test case 8. Being able to strongly cast or coerce types when needed
9. Support for verbose, warning, and debug streams to provide additional test information 10. Being able to use PowerShell's systems administration features to help setup or cleanup a
test environment
Use of PowerShell in Unit Testing
is a software verification and validation
method in which a programmer tests if
individual units of source code are fit for
use – In Wiki’s terms
10