Showing posts with label AdsiPS. Show all posts
Showing posts with label AdsiPS. Show all posts

2016/08/22

PowerShell/Pester - Make sure your Comment Based Help is not indented


While writing some PowerShell Pester tests for my module AdsiPS, I wanted to make sure for each functions that all the help keywords of the comment based help were not indented.

Depending of the script editor you are using, the number of spaces or tabs might differ and once published on GitHub the code might looks not so pretty.


My goal is just to keep my code clean and enforce the same practice across all the functions.

Here for example, I don't want this:
Instead, I want all the comment based help in that format


2016/05/11

Using Pester to test your Manifest File

In my previous post I got started with Pester and wrote my first test against the Comment Based Help of my module AdsiPS.

Next, I wanted to write a Pester test against the Manifest File of AdsiPS module. I want to make sure all the basic information of the module is referenced in this file. Mike Robbins wrote a great article on Dynamic Unit Tests where he is touching some of the points I want to cover today.


But before I get into the code, a small reminder on the Manifest file's role.

What is a Manifest File ?


A module manifest is a Windows PowerShell data file (.psd1) that describes the contents of a module and determines how a module is processed. The manifest file itself is a text file that contains a hash table of keys and values. You link a manifest file to a module by naming it the same as the module, and placing it in the root of the module directory.

For simple modules that contain only a single .psm1 or binary assembly, a module manifest is optional. However, it is recommended that you use a module manifest whenever possible, as they are useful to help you organize your code and to maintain versioning information. More info.
(You'll find at the end of this article the command that I use to generate my manifest.)


2016/05/10

Using Pester to test your Comment Based Help

Update 2016/11/25: Updated the code to support functions where there is no parameter declared (Thanks Wojciech Sciesinski !!!)

I remember attending a meeting on Pester presented by Dave Wyatt back in November 2014 during my first MVP Summit.

A couple of well known PowerShellers were there: Boe Prox, Emin Atac, Adam Driscoll, Mike Robbins, Fabien Dibot, Jan Egil Ring, Steve Murawski, ...  It was a great event, great to finally meet all those guys...

Anyway, at the time Pester looked pretty neat but since I only played with it a couple of times and never really invest or commit myself to create tests for each of my scripts or modules.

During the Microsoft MVP Summit 2014 week (Bellevue, WA, USA)
Evening event organized by Dave Wyatt on Pester.