Skip to content

Add some unit tests and integration tests, fix a new-pat arg issue - #266

Merged
Michael Smith (Exolun) merged 6 commits into
microsoft:developfrom
Exolun:user/mismit/update_packageconfig_tests
Aug 12, 2024
Merged

Add some unit tests and integration tests, fix a new-pat arg issue#266
Michael Smith (Exolun) merged 6 commits into
microsoft:developfrom
Exolun:user/mismit/update_packageconfig_tests

Conversation

@Exolun

Copy link
Copy Markdown
Contributor

This pull request includes a bunch of end to end tests and unit tests.

The end to end tests work by prompting the user to enter a series of Unity directories that exercise the test scenarios, and an azure subscription GUID to test the new AzureSubscription arg. It is by no means comprehensive, but it should more or less covers all of the valid happy paths. At the time of this PR there are 15 of these tests.

Similarly there is also a body of unit tests - these tests are mostly identical to the e2e tests except they use mocks heavily. Realistically the unit tests really don't test much because of how little of the underlying code actually runs. In fact, due to the support of $PSCmdlet.ShouldProcess, I found it nigh-impossible to even mock/test Update-PackageAuthConfig, which is where most of the interesting code paths lie.

Pester was fairly easy to work with, but I did find that the execution scope that the tests are run within makes it quite challenging to reuse code and do anything elaborate with the mocking - hence the lack of shared code across the two test files.

@jwittner Josh Wittner (jwittner) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small requests, but this is an AWESOME contribution to lay the foundation for improved testing!

Comment thread Tests/UnitTests/Update-UnityPackageManagerConfig.Tests.ps1 Outdated
Comment thread Tests/unittests.ps1

@jwittner Josh Wittner (jwittner) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates look awesome! Only nit would be to ignore the TestResults.xml from any path so that we can run the script from anywhere.

@Exolun

Copy link
Copy Markdown
Contributor Author

Updates look awesome! Only nit would be to ignore the TestResults.xml from any path so that we can run the script from anywhere.

Sounds good - since I will be OOF next week I think I'll merge this and create a branch withTestResults.xml change to gitignore for a fast-follow up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants