![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Embedded testing method in scripts? Is there a standard way to embed a testing method within a script? What I'm looking for is something similar to the idiom you seen in Python at the bottom of .py files to include a component for testing? In Python it is often used for creating an entry point for something that might otherwise be used as a function library, but it can also be used for testing. if __name__ == '__main__': Do_something() I'm trying to implement something like this but it is very verbose and feels kludgy. -Mike |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Embedded testing method in scripts? On Jun 9, 3:18 am, Mike Schinkel <mikeschin...@gmail.com> wrote: > Is there a standard way to embed a testing method within a script? > What I'm looking for is something similar to the idiom you seen in > Python at the bottom of .py files to include a component for testing? > In Python it is often used for creating an entry point for something > that might otherwise be used as a function library, but it can also be > used for testing. > > if __name__ == '__main__': > Do_something() > > I'm trying to implement something like this but it is very verbose and > feels kludgy. > > -Mike I suppose it depends on the script. If it's basically expressed asa series of functions, it's pretty easy to call them individually by adding this entry point immediately below the last function statement: if ($args[0] -ne $null) { &$args[0] ; exit } Then test individual functions like so: foo-bar.ps1 {function1 arg1 arg2 etc}. Or make a special test function that calls a set of other functions in a specific order, etc. I've found that in some cases, it's very handy to write whole scripts as linked functions because of the flexibility it gives in situations like this. Otherwise there's the -whatif switch. ![]() -Hecks |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Embedded HTA | David Bray | VB Script | 10 | 07-24-2008 05:51 PM |
| Method invocation failed because [System.String] doesn't contain a method | B Williams | PowerShell | 0 | 03-31-2008 06:00 PM |
| Embedded swf does not execute | Ralph W | Vista mail | 1 | 06-11-2007 02:50 PM |
| Color of WMP Embedded | Muffin | Vista music pictures video | 0 | 02-22-2007 07:55 AM |
| Updated: PowerShell Scripts for Testing | Adam Geras | PowerShell | 2 | 02-07-2007 05:02 PM |