Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR Metrics: Update tests to Pester 5.0+ idioms #4

Closed
muiriswoulfe opened this issue Nov 4, 2020 · 1 comment
Closed

PR Metrics: Update tests to Pester 5.0+ idioms #4

muiriswoulfe opened this issue Nov 4, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@muiriswoulfe
Copy link
Member

Before the PR Metrics extension was open sourced, it was limited to using Pester 3.0. This older version of Pester resulted in many constraints when writing unit tests, which are no longer necessary following the upgrade (as part of open sourcing) to Pester 5.0. In addition, the API differences between Pester 3.0 and Pester 5.0 are significant and in many cases the legacy APIs are being used.

This task is to track upgrading the tests from Pester 3.0 idioms to Pester 5.0 idioms. This work should comprise:

  • Fixing the mocks to use the new idioms. The old idioms will eventually become unsupported, so moving to the new idioms will be necessary at some stage.
  • Extracting out mocks where possible, to avoid repetition.
  • Less reliance on console printing to validate calls have been made successfully. This will accelerate adding new functionality as it will require fewer test changes.
  • Better validation of JSON payloads. The payloads can differ depending on the environment in which they are run, which has led to incomplete JSON payload validation in the tests as a workaround. The guidance at https://dscottraynsford.wordpress.com/2015/08/23/comparing-objects-using-json-in-powershell-for-pester-tests/ can be used to help resolve this issue.
  • Better validation of array/collection response types. These responses can differ depending on the environment in which they are run, so all reliance on ordering should be removed for improved robustness.
  • Better use of mocks to increase the number of unit tests and reduce the number of integration tests.
  • Better splitting of the tests between unit and integration tests.
  • Re-enabling test coverage.

Information on migrating Pester tests can be found at https://pester.dev/docs/migrations/v3-to-v4 and https://dsccommunity.org/blog/converting-tests-to-pester5/, and the Pester docs can be found at https://pester.dev/.

Note that this is best implemented via a series of changes given the significant volume of issue highlighted above. If done incrementally, the change should be manageable.

@muiriswoulfe muiriswoulfe added the enhancement New feature or request label Nov 4, 2020
@muiriswoulfe
Copy link
Member Author

No longer required as issue #5 is being addressed, which makes this issue redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant