The Failed Tests

55 views
Skip to first unread message

Joaquin Menchaca

unread,
Aug 17, 2014, 7:08:51 PM8/17/14
to pash-p...@googlegroups.com

As there was interest in the failures as well, I will post them.

Background on such scripts.  I think these are similar to use case type of scripts (and thus maybe worked into some BDD-style).  They focus on what typical types of script functionality is used for system administration oriented tasks.  The use cases and operations come from what you can do in a POSIX shell, then carrying these ideas to other scripting platforms, like ruby, python, perl, groovy, vbscript, and powershell.  I plan to create some kick-ass website about it (rolls eyes… once I get around to it naturally).

It just so happens, I was asking myself, wouldn't it be awesome if I could run powershell scripts on Unix|Linux|Mac-OS-X?  And voilá, I found this project.  So I am rather excited.  I would be interested to learn how to do unit tests and integration test.  I came across a scripting challenge in a job interview for Python, and they used some sort of unit tests, and I had to make sure my implementation passed the unit tests.  I thought this was really cool way to program, it was like a race, challenge, to pass the unit tests.  I would be a newbie in this category, but then, newbies often make the best testers.

1. Output
   * multi-line output using @" ... "@
2. Variables
   * formatted output fails "Number is {0}." -f $num
   * multi-line strings using $phrases = @" .. "@
3. Arithmetic
   * show basic integer arithmetic
   * show basic floating math with exponential
   * show basic math function like cosine
4. Input
   * input a string
     * demonstrate using Read-Host
5. Branch
   * test a string using if
     * NOTE: building string outputs string, when it is not last used in output stream.
   * test a string using if to determine slice on anonymous list
   * test a number range
   * test a number for menu selection
     * demonstrate string comparison
   * multi-way test on a number for menu selection
     * demonstrate numerical comparison
     * demonstrate string comparison   
   * multi-way test on single character with pattern matching
   * test on single character with pattern matching
     * NOTE: cmatch not supported.
6. Looping
   * collection loops on directory listing and PsIsContainer to test for a directory
     * demonstrate using switch to process the collection
   * count style loop
     * demonstrate using while looping construct
   * conditional loop
     * demonstrate using do...while() loop construct
     * demonstrate using do...until() loop construct
     * demonstrate using while() loop construct
   * spin loop
     * demonstrate using do...while(1) with break to exit loop
   * spin loop with ability to skip invalid input
     * demonstrate using do...while(1) with continue to skip to next iteration
7. Arrays
   * Array Initialization
      * initialize array one element at a time
        * demonstrate using concatenation operator + to append an element to an array
      * enumerate all elements
   * Array Enumeration
      * enumerate array with an index
        *  demonstrate using general for to increment the index
8. Associative Arrays
   * Associative Array Initialization
      * initialize associative array by key
      * enumerate all keys
      * enumerate all values
   * Associative Array Enumeration
      * declare and initialize associative array
      * merge two associative arrays
      * enumerate associative array by key
        *  demonstrate using collection loop with foreach
9. Subroutines
   * demonstrate declaring and calling subroutine
     *  demonstrate showing formatted date with Get-Date -UFormat
   * demonstrate subroutine referencing global variables
     *  this shows using $global:variable
   * demonstrate subroutine explicitly using local variables
     *  this shows using $global:variable
10. Arguments
    * demonstrate processing 2 arguments
      * **NOTES:** Retrieving the script name can be done using $MyInvocation.MyCommand.Name
    * demonstrate printing all arguments
      * use collection loop foreach
      * use count style loop with for and a range built using ..
    * demonstrate printing arguments in reverse order
      * use count style loop with for and a range built using ..
11. Parameters
    * demonstrate passing a single parameter
      * demonstrate controlling degrees of significance with decimal numbers
    * demonstrate passing unlimited parameters
12. Exiting
    * demonstrate exiting with error code to communicate status
13. Functions
    * demonstrate function that returns an int
    * demonstrate function that returns a string
      * string is capitalized using ToUpper() method
    * demonstrate function that returns an array

Stefan Burnicki

unread,
Aug 18, 2014, 8:36:10 AM8/18/14
to pash-p...@googlegroups.com
Hey Joaquin,

thanks for your testing feedback. Unfortunately it's sometimes a bit hard to see the exact problem just by what's not working.

and that's exactly why also the Pash project includes unit tests, and since some hours also some kind of integration tests, thanks to Johannes.
Feel free to check out our unit tests in the project. As you will see, there isn't much overhead in writing them.
In the project, you can find in the Source/ReferenceTests directory and subdirectories many files with different unit tests.
There is also one subdirectory called "Integration" with currently two files that include many small scripts.
As you will see, many tests are curently made "explicit" as they don't work with pash, yet. But it's a nice goal to get them working :)

If you have time, feel free to check this code out and provide more tests in just another file! And if you have questions about it, please ask :)

Regards,
Stefan

Joaquin Menchaca

unread,
Aug 18, 2014, 7:44:59 PM8/18/14
to pash-p...@googlegroups.com
Thank you.  I will look into this.  Maybe if anyone has time, I get a tutorial (skype, gchat) to introduce me into this world. I'm exited about unit testing, having come across it in an job interview where I had to craft python class to pass the test.  I used to do SQA long ago back during * cough * waterfall days.  But that skill set is obsolete.  I am interested because I love automation, and this is just another part of the whole picture.
Reply all
Reply to author
Forward
0 new messages