Skip to content

contains various classes and a nuget package for testdriven development of PowerShell cmdlets

Notifications You must be signed in to change notification settings

zimmybln/powershelltestingframework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

PowerShell Testing Framework

The PowerShell Testing Framework enables to develop PowerShell cmdlets test driven. It contains various tools, base class etc. to execute PowerShell scripts within your Visual Studio combined with your favorite testing tool. You may use within your script common commands and/or your custom cmdlets and you have the opportunity to inspect nearly all kinds of output, variables and results.

Sample

This sample uses XUnit as testing execution framework. The test AddContactWithExplicitParameter executes the script and checks if any errors occures. Finally it checks some assumtions about the result of the execution. The testfixture adds the module containing the custom cmdlet Add-Contact.

    public class AddContactTests : PowerShellTestBase
    {
        public AddContactTests(ITestOutputHelper output) : base(output.WriteLine, typeof(AddContactCmdlet).Assembly)
        {

        }

        [Fact]
        public void AddContactWithExplicitParameter()
        {
            var script = $@"

                        Add-Contact -FirstName 'Martina' -LastName 'Mustermann'

                        ";

            var result = RunScript(script);

            Write(result); // show the full output, including Debug, Warnings, Errors etc.

            var contact = result.Output.OfType<Contact>().FirstOrDefault();

            Assert.False(result.Errors.Any());
            Assert.NotNull(contact);
            Assert.True(contact.Id > 0);
            Assert.Equal("Martina", contact.FirstName);
            Assert.Equal("Mustermann", contact.LastName);

        }
    }

NuGet

You'll find the binaries at nuget here:

Install-Package Zimmy.PowerShell.Testing.Framework -Version 1.0.0

It is the first release without any documentation except a lot of test and samples.

Wiki

https://github.com/zimmybln/powershelltestingframework/wiki

About

contains various classes and a nuget package for testdriven development of PowerShell cmdlets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages