Skip to content

Improve reliability (and speed) of UT's be transitioning to rely on a mock of Invoke-WebRequest #267

Open

Description

Feature Idea Summary

Trying to fix #264 has made me start to rethink how we're performing tests within this module.
I think it is imperative that we continue to have tests that perform end-to-end testing of the module against the API, however I think we can probably reduce our reliance on those tests from being 100% of our tests to being closer to 20% of our tests. For the other 80%, I think we can switch to using mocks. My current thinking is that we'd only need to mock out Invoke-WebRebquest.

Feature Idea Additional Details

  • I think that for any given endpoint that we are contacting, we need to have at least one true end-to-end test to verify that we're interacting correctly with the API.
  • For the rest of the API's, we should be verifying that what we're sending to the API is correct. So, we would mock out Invoke-WebRequest, and the mock should expose the Uri, Method, Headers, InFile, OutFile, and Body so that they can all be successively verified by the tests. The mock will need to be able to return back a valid-looking success object, but it doesn't need to have any real content (it could just be a 202 with no body). It OutFile was specified, it will need to create an empty text file at that location.

Taking this approach should dramatically speed up the overall runtime of the UT's, while reducing the unreliability we've been seeing lately with the existing UT's when running live against GitHub in our CI build.

Requested Assignment

I'm just suggesting this idea, but don't want to implement it.

Operating System

OsName               : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 1909
WindowsBuildLabEx    : 18362.1.amd64fre.19h1_release.190318-1202
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module Version

Running: 0.14.0
Installed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    discussionWe are looking for additional community feedback on this topic before proceeding further.enhancementAn issue or pull request introducing new functionality to the project.help wantedAnyone in the community is welcome to do this worktestsA change related to the Pester tests for the module.up for grabsAnyone in the community is welcome to do this work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions