Run Pester tests in PowerShell ISE with IsePester

Today I stumbled upon a package in chocolatey that I wasn’t aware of. It’s called IsePester from @dfinke. If you develop you PowerShell scripts with ISE and run Pester tests this is a really nice package. If you haven’t played around with chocolatey – do it. It’s a really need packaging manger that makes setting up your dev machines really easy. To install chocolatey just run the following command in PowerShell: To use Pester you have to install it. If it is already installed you can override it with -–force / -f Install IsePester the same way… If you now … Continue reading Run Pester tests in PowerShell ISE with IsePester

Use Pester to author your PowerShell scripts

Pester is a great module for testing your PowerShell scripts and modules. It has great mocking support, a test drive for setting up isolated files and supports a lot of assertions. Since the importance of PowerShell growths, testing your scripts is a must.

This is part 2 of the series “Develop next level PowerShell with Visual Studio and Pester”. It assumes that you have a Visual Studio solution with a basic Pester Test in GitHub.

Post Content
Part 1: Develop next level PowerShell with Visual Studio and Pester In this post I focus on creating the project in Visual Studio and interacting with a source control system like git.
Part 2: Use Pester to author your PowerShell scripts using TDD/BDD This post focuses on writing PowerShell scripts or modules using Pester as a TDD/BDD framework.
Part 3: Run your Pester tests in a VSTS build In this post I show you how you can run you tests in a continuous integration build and display the build status with a badge in your repository.


Pester basics

If you create a new test in Visual Studio, it looks like this:

Describe "PowerShellTest1" {
    Context "Exists" {
        It "Runs" {

As you can see you have three levels:

Describe: This is the name of the test displayed in test explorer. It is not ONE test in the test results. It’s more a container scope for many tests that executes as a unit.

Context: Like “Describe” the Context is a container for tests. You can mock functions or have test files in the scope of a context.

It: “It” is the actual test. You add an assertion here to test the state of your system. “It” is also a scope for mocking like context.

You can use these elements to structure your tests in a BDD style after the GivenWhenThen pattern.

$project = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace(".Tests", "")
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".tests.", ".")
. "$project\$sut"

Describe "AnswerToUltimateQuestion" {
    Context "Given an enormous supercomputer named Deep Thought, when we ask the ultimate question about life, the universe, and everything" {
        It "should return 42" {
			       AnswerToUltimateQuestion | Should Be 42

Continue reading “Use Pester to author your PowerShell scripts”

New Version of SPEmulators available on nuget

Today I released a new version of the SPEmulators – the package to emulate SharePoint Server API in Farm Solutions – on nuget. The current version is 2.0. The current version includes: Support for Visual Studio 2015 Enterprise Fixed errors for some editions of VS 2012 and 2013 Included Pull Request from Vladimir Almaev with support for SPViewFieldCollection Fixed some minor bugs For installing and using the package please refer to my original post. If you have any questions, issues or feature requests, please create an issue on the project page on GitHub. Continue reading New Version of SPEmulators available on nuget

SPOEmulators 0.2-pre released on nuget

I had no support for Visual Studio 2015 in my first beta. I fixed this and added a pester test script to test the init.ps1. I also notices that there are problems with older versions of SharePoint on premises. Therefor I created a second nuget package. The original package SPOEmulators now uses the dependent package Microsoft.SharePointOnline.CSOM as the source for the CSOM assemblies (version 16). The new package SPOEmulators (on-premises) directly references the version 15 of the CSOM assemblies. For details how to use the SPOEmulators refer to the readme on or to my original post here. Continue reading SPOEmulators 0.2-pre released on nuget

SPOEmulators beta available

Today I published the first beta of SPOEmulators on The project is open source (MIT license) and is available on GitHub. SPOEmulators is a framework that helps you to write unit and integration tests against Office 365 or SharePoint on premise using the client side object model (CSOM). It uses the Microsoft Fakes Framework to emulate the SharePoint or O365 CSOM. The benefit is, that you an write your tests against the real backend as integration tests. If your code works you can add a little more effort to convert the test to an isolated unit test. Like this … Continue reading SPOEmulators beta available

SPEmulators v1.1.0 available

I just released the new Version (v1.1.0) of the #SPEmulators on nuget. The release contains the following changes: Support for test projects that target .net 4.5 (previous 4.5.1) Support for VS Premium with version 2012 Update 2 or higher (thanks to Tiliavir for the support) The assembly is now signed Added support to create lists by schema.xml and elements.xml to GetOrCreateList The last feature is quite experimental. There is support for fields (text, number, date, user, lookup) from schema.xml. There is also support for the basic properties in the elements.xml. I also added support for default data that is deployed … Continue reading SPEmulators v1.1.0 available

SPEmulators available on nuget

Every SharePoint developer that does TDD is desperately waiting for Microsoft to release a Version of the Microsoft.SharePoint.Emulators for SharePoint 2013. Unfortunately it seems that Microsoft does not have any plans to publish a new release in the near future. This is completely incomprehensible since there are a lot of SP2010 solutions that must be migrated to SP2013. To close the gap there is now the the nuget package SPEmulators. The source code is available in a repository on GitHub. Installation To install SPEmulators, run the following command in the Package Manager Console: Install-Package SPEmulators. You can also search for … Continue reading SPEmulators available on nuget