-
Notifications
You must be signed in to change notification settings - Fork 141
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
ActiveDirectoryDsc: Add stubs to be used with unit tests #245
Comments
I tried to use @indented-automation's module https://github.com/indented-automation/Indented.StubCommand to generate the full stubs, but ran into a couple of issues (that I could not solve on my own). See the README.md my branch here https://github.com/johlju/xActiveDirectory/tree/add-stubs/Tests/Unit/Stubs which also links to the issues. Feel free to continue this work and make it better. 😄 |
There seems to be a problem with the build worker loading in the assemblies so that classed are present, that means that our stub classes (for example I think this can have something to do with the meta tests running (common tests in the test framework) that imports this module for some reason. |
I suggest we simplify the stubs of the AD cmdlets. Parameters in the cmlets are today referencing various ActiveDirectory classes which also demands that we need to have stubs for those classes. I suggest that we just change all the stub cmdlet parameters to use I think this would lower the bar for new contributors to write tests. Using |
- Changes to ActiveDirectoryDsc - Added new stubs for the cmdlets and classes to be used with unit tests. The new stubs are based on the modules ActiveDirectory and ADDSDeployment in Windows Server 2019. The stubs are generated using the PowerShell module *Indented.StubCommand*. Instructions how to generate stubs (for example for a new operating system) has been added to the README.md in the `Tests/Unit/Stubs` folder ([issue #245](#245)). - Update all unit tests removing all local stub functions in favor of the new stub modules. - Changes to ActiveDirectoryDsc.Common. - Updated the function `Test-ADReplicationSite` to make the parameter `Credential` mandatory.
I think we need to add stubs to use in the unit tests, similar that was done in SqlServerDsc https://github.com/PowerShell/SqlServerDsc/tree/dev/Tests/Unit/Stubs.
For example there is no need to add helper functions to support mocking (which lowers the code coverage also). An example is here, a function that was added because we are missing stubs.
https://github.com/PowerShell/xActiveDirectory/blob/e4817bf4fa710c79455816a56a20665bd0dd1162/DSCResources/MSFT_xADReplicationSiteLink/MSFT_xADReplicationSiteLink.psm1#L300-L326
The text was updated successfully, but these errors were encountered: