Author Posts

May 25, 2017 at 8:45 am


Is it good practice to *always* provide a tag on tests? I'm thinking of using "unit" as a default tag on tests, and different tags ("integration", "regression" etc) for non-unit tests. By default then invoking pester will run all tests, and I can run specific tests using IncludeTags. I realise I could get the same result using excludeTags but thinking being explicit with tags might provide a bit more flexibility.


May 25, 2017 at 1:28 pm

Hi Dave,

It's completely up to you to use tags or not. You mentioned tagging tests as "unit". That's possible but I, personally, create different files for unit/integration tests. It's just a different way of grouping. People also use tags to indicate tests for different versions of PowerShell, different OSes, etc. There's really no "recommended" way to use them that I know of.

May 25, 2017 at 1:36 pm

Hi Adam. Thanks for the response. To add a bit more info, I'm working on a project that includes around 10 modules and dozens of functions. So I'm specifically referring to testing the entire project in one go rather than say just a single *.unit.tests.ps1 (or *.integration.tests.ps1) file.

So basically I'm trying to ensure I can easily test the whole solution, or if need just run all "unit" tests, or all "integration" tests. Do you find you can still easily achieve that my not using tags and separating the tests into unit/integration test files?


May 25, 2017 at 1:40 pm

I've actually create a small framework around Pester tests that allow me to do things like Start-UnitTest, Start-IntegrationTest, etc. This allows me to have better control over things like you're talking about.

Here's a writeup I did on it.,1-3418.html

May 28, 2017 at 7:45 pm

Ah, I see. So you've basically replaced the tags functionality with a more flexible way of invoking different tests or specific modules or functions. Nice.

In your Start-PesterTest function though, after you invoke Pester what is the purpose of the invoking it again with "$steppablePipeline.Begin"? (Lines 47-50).

May 28, 2017 at 9:40 pm

That was from creating a proxy function. I've updated it since then. I should probably get that new code up there. 🙂