Git Product home page Git Product logo

dscresource.tests's Introduction

DscResource.Tests

Common meta tests for PowerShell DSC resources repositories.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

DscResourceCommonTests

Unreleased

  • Extra whitespace trimmed from TestHelper.psm1 (feature of VS Code).
  • Removed code to Remove-Module from Initialize-TestEnvironment because not required: Import-Module -force should do the same thing.
  • Initialize-TestEnvironment changed to import module being tested into Global scope so that InModuleScope not required in tests.
  • Fixed aliases in files
  • Initialize-TestEnvironment changed to update the execution policy for the current process only
  • Restore-TestEnvironment changed to update the execution policy for the current process only.

0.2.0.0

  • Fixed unicode and path bugs in tests

0.1.0.0

  • Initial release

DscResourceTestHelper

Unreleased

0.2.0.0

  • Fixed unicode and path bugs in tests

0.1.0.0

  • Initial release

Goals

  1. Consistency in encoding and indentations. Consistency is good by itself. But more important it allows us to:
  2. Avoid big diffs with cosmetic changes in Pull Requests. Cosmetic changes (like formatting) make reviews harder. If you want to include formatting changes (like replacing " by '), please make it a separate commit. This will give reviewers an option to review meaningful changes separately from formatting changes.

Git and Unicode

By default git treats unicode files as binary files. You may not notice it if your client (like VS or GitHub for Windows) takes care of such conversion. History with Unicode files is hardly usable from command line git.

> git diff
 diff --git a/xActiveDirectory.psd1 b/xActiveDirectory.psd1
 index 0fc1914..55fdb85 100644
Binary files a/xActiveDirectory.psd1 and b/xActiveDirectory.psd1 differ

With forced --text option it would look like this:

> git diff --text
 diff --git a/xActiveDirectory.psd1 b/xActiveDirectory.psd1
 index 0fc1914..55fdb85 100644
 --- a/xActiveDirectory.psd1
 +++ b/xActiveDirectory.psd1
@@ -30,4 +30,4 @@
   C m d l e t s T o E x p o r t   =   ' * '

   }



 -
 \ No newline at end of file
 + #   h e l l o
 \ No newline at end of file

Command line git version is a core component and should be used as a common denominator.

MetaFixers Module

We are trying to provide automatic fixers where it's appropriate. A fixer corresponds to a particular test.

For example, if Files encoding test from Meta.Tests.ps1 test fails, you should be able to run ConvertTo-UTF8 fixer from MetaFixers.psm1.

TestHelper Module

The test helper module (TestHelper.psm1) contains the following functions: New-Nuspec: Creates a new nuspec file for nuget package. Install-ResourceDesigner: Will attempt to download the xDSCResourceDesignerModule using Nuget package and return the module. Initialize-TestEnvironment: Initializes an environment for running unit or integration tests on a DSC resource. Restore-TestEnvironment: Restores the environment after running unit or integration tests on a DSC resource.

Templates for Creating Tests

The Template files that are used for creating Unit and Integration tests for a DSC resource are available in the DSCResources GitHub Repository in the Tests.Template folder

To use these files, see the test guidelines document and the instructions at the top of each template file.

The resource files are: *Unit_Template.ps1**: Use to create a set of Unit Pester tests for a single DSC Resource. Integration_Template.ps1: Use to create a set of Integration Pester tests for a single DSC Resource. Integration_Config_Template.ps1: Use to create a DSC Configuration file for a single DSC Resource. Used in conjunction with Integration_Template.ps1.

Example Test Usage

To see examples of the Unit/Integration tests in practice, see the xNetworking MSFT_xFirewall resource: Unit Tests Integration Tests Resource DSC Configuration

Example Usage of DSCResource.Tests in AppVeyor.yml

To automatically download and install the DscResource.Tests in an AppVeyor.yml file, please see the following sample AppVeyor.yml. https://github.com/PowerShell/DscResources/blob/master/DscResource.Template/appveyor.yml

dscresource.tests's People

Contributors

bgelens avatar dan1el42 avatar dcrreynolds avatar eshaparmar avatar karolkaczmarek avatar kusuriya avatar kwirkykat avatar lfshr avatar mbreakey3 avatar nabrond avatar narrieta avatar plagueho avatar powershellteam avatar travisez13 avatar vors avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.