Automated Module Testing – Part 1

Hi all,

As your probably know if you’re reading this blog, I’ve made a Powershell module dedicated to MS Excel. Very Often I do some refactoring and code updates but it is very difficult to be sure before a new release that every little changes I’ve made didn’t introduced some bug… This is a real problem and because I do this during my free time, it is not possible for me to test everything… Many times, by modifying my code I introduced new bugs so I decided to create something to aggregate my code before each release. The code isn’t finished for the moment but… I’ll release it very soon !

For the moment, my code does the following :

  • Retrieve all the Cmdlet of a module
  • Retrieve all the parameters of each Cmdlet
  • Build all the possible combination between all parameters (Taking care of the parameter set, of what is mandatory, what is optional and what could come from the pipeline)
  • Create Script blocks with every parameters you must provide to test all the possibilities but maybe an example will be better to show you what I mean… Just have a look at what comes after this list 😉

Imagine, You have this Cmdlet that is part of a module :

My Script tester would generate the following code (The function name is not valid, I must suppress all “-” from the original Cmdlet… It’s just a theoretical example) :

As you can see for the moment the output is not tested, you can just rely on no error or exception to validate the combination. Of course, my next goal will be to add the possibility to enter the expected result 😉 But I’m on my way… Stay tuned and Bye Bye !

ExcelPSLib Source Code

ExcelPSLib is a PowerShell Module that allows creation of XLSX file by using the EPPlus 3.1 .Net Dynamic Link Library available at and made by Jan Kallman.

The goal of the ExcelPSLib Powershell Module is to add as much as possible an abstraction layer between .NET and Powershell by providing convenient “cmdlets”.

ExcelPSLib is intended to Admins who want to create easily and in no time an XLSX file output for their Powershell scripts instead of an XML/XSLT, CSV File or even worse a TXT file because If you work within a Microsoft infrastructure the XSLX format is the most valuable format for every one in your company… And this With no special knowledge requirement 😉

Here is the source code of my Powershell module : ExcelPSLib. The lastest version is Alpha 0.5.8 an offers the following features :

  • Create and configure an ExcelPackage
  • Create and configure a new workbook
  • Create and configure worksheet(s)
  • Create style sheet (font, style, display and alignment options)
  • Set value of a cell, assign the row where is the cell to a group
  • Apply style sheet to range of cells (font, style, display and alignment options)
  • Conditional formatting of range(s) with style sheets (font, style, display and alignment options)
  • Create basic pivot table
  • Convert decimal coordinate to Excel coordinates
  • Export an array of objects to an XLSX file with header with auto-filter and 4 conditional formatting style available for an unlimited number of conditions
  • Save the Current ExcelPackage to an XLSX file
  • Import and convert an XLSX file to an array of object