Run your Pester tests from GitHub in a VSTS/VSO build
End-To-End Scenario how to author PowerShell with Visual Studio, GitHub and Pester and test your script in Visual Studio Team Services VSTS / VSO. Continue reading Run your Pester tests from GitHub in a VSTS/VSO build
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”
Develop next level PowerShell with Visual Studio and Pester
End-To-End Scenario how to author PowerShell with Visual Studio, GitHub and Pester and test your script in Visual Studio Team Services VSTS / VSO. Continue reading Develop next level PowerShell with Visual Studio and Pester
WLW Plugin for Open Live Writer #OLW available
I use Windows Live Writer for quite some time to write my post for my WordPress blog. The last version that was published by Microsoft was in the year 2012. So I was very happy when a few days ago the Open Live Writer (OLW) was announced. The OLW is an open source clone of the Windows Live Writer and is supported by a group of volunteers. Check out the post from Scott Hanselman for more details. What kept me from using it until now was the missing WLW Pluging (The Live Writer Source Code Plug-in For WordPress.com Blogs) from … Continue reading WLW Plugin for Open Live Writer #OLW available
Set assembly and app version to a matching build name in TFS 2015 or VSO Build.VNext
One of the most common customizations in TFS XAML build templates was to automatically update the assembly version number. This can also be done in build vNext using a small power shell script. I also added the option to apply … Continue reading Set assembly and app version to a matching build name in TFS 2015 or VSO Build.VNext
Trigger a vNext Release from build in TFS 2013/2015 on premise
I always had a lot of problems triggering a release from a build (Vnext or Xaml) on premise if I work with agentless deployments. In the cloud this works like a charm – but on premise it never worked for me. I tried it with the blog post on msdn – but no success. Today I started to use Fiddler to monitor the api calls that the Release Management Client makes. (BTW: I know now, why the app is so slow if you have limited network bandwidth. The client is really chatty!). With Fiddler and the Invoke-RestMethod commandlet its quite … Continue reading Trigger a vNext Release from build in TFS 2013/2015 on premise
Visual Studio Release Management and PaaS
Can you deploy Platform as a Service (PaaS) components to Azure using Visual Studio Release Management? I get this question quite often lately. Short answer: yes you can. And how? Via a virtual machine. Yes – this is Infrastructure as a Service (IaaS) and not PaaS. Yes – this is not what you expected. Me neither. But it’s the only supported way right now. I hope this will change in future versions and that we get a “Azure PowerShell” like we have in Build.VNext. But right now this is the way to go. If you watch BREAKPOINT: Release Management and … Continue reading Visual Studio Release Management and PaaS
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 github.com 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 NuGet.org. 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