More CLI test automation plumbing. #8746
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes significant changes to improve the testability of the CLI. Here is a summary of what is going on with this change:
InteractionUtils
into a new service that we can inject into DI calledInteractionService
with an abstract interface that we can mock out if we need to.AppHostHelper
into a newIProjectLocator
type which allows us to mock out some of the filesystem scanning logic in the future.CertificateHelper
logic into aCertificateService
which allows us to override certificate handling behavior in tests.INewCommandPrompter
which captures some of the specific prompt operations for theNewCommand
which has its happy path tested in this PR. The reason for having this additional interface is that it makes it easier to mock out just the specific operations that you want to intercept and have some specific automated fallbacks (e.g. selecting the first template, selecting the first template version, and accepting default project names and output paths). This interface has optional callbacks which can be populated to change the behavior on a per test basis.The structure of a command test therefore looks something like this: