en-US/about_PesterConfiguration.help.txt
|
TOPIC
about_PesterConfiguration SHORT DESCRIPTION Pester uses a PesterConfiguration-object to configure all of it's options. It is the source of truth for the defaults and provides all supported options. LONG DESCRIPTION Pester can be invoked using either a limited set of parameters in Invoke-Pester (Simple interface) or by providing a PesterConfiguration object (Advanced interface) that supports all available options. When Invoke-Pester is invoked using the simple parameters it is internally translated to a full configuration-object, using the default values for any undefined options. The configuration object can be navigated interactively in the console to view all options including description, current and default values. EXAMPLE Below we can se an example of how to run Pester using a configuration object: # Get default configuration $configuration = New-PesterConfiguration # Changing a few options including the path for our test files. $configuration.Run.Path = '.\tests' $configuration.Filter.Tag = 'Acceptance' $configuration.Filter.ExcludeTag = 'WindowsOnly' $configuration.Output.Verbosity = 'Detailed' # Run Pester Invoke-Pester -Configuration $configuration SECTIONS AND OPTIONS Run: Path: Directories to be searched for tests, paths directly to test files, or combination of both. Type: string[] Default value: @('.') ExcludePath: Directories or files to be excluded from the run. Type: string[] Default value: @() ScriptBlock: ScriptBlocks containing tests to be executed. Type: scriptblock[] Default value: @() Container: ContainerInfo objects containing tests to be executed. Type: Pester.ContainerInfo[] Default value: @() TestExtension: Filter used to identify test files. Type: string Default value: '.Tests.ps1' Exit: Exit with non-zero exit code when the test run fails. Exit code is always set to `$LASTEXITCODE` even when this option is `$false`. When used together with Throw, throwing an exception is preferred. Type: bool Default value: $false Throw: Throw an exception when test run fails. When used together with Exit, throwing an exception is preferred. Type: bool Default value: $false PassThru: Return result object to the pipeline after finishing the test run. Type: bool Default value: $false SkipRun: Runs the discovery phase but skips run. Use it with PassThru to get object populated with all tests. Type: bool Default value: $false Parallel: EXPERIMENTAL: Run test files in parallel, each file in its own runspace, using PowerShell 7+ 'ForEach-Object -Parallel'. Files that contain the '#pester:no-parallel' directive run sequentially after the parallel batch. Falls back to a sequential run on Windows PowerShell 5.1, when non-file containers (ScriptBlock) are used, when CodeCoverage is enabled, or when Run.SkipRemainingOnFailure is set to 'Run'. Type: bool Default value: $false BeforeContainer: EXPERIMENTAL: One or more ScriptBlocks run before each test file is discovered and run, in both sequential and parallel runs. Use it to import helper modules or dot-source setup that the parent session would normally provide, e.g. { . './setup.ps1' } - this is especially useful in parallel runs, where each worker starts from a clean runspace. One scriptblock is usually enough and can dot-source as many files as needed. When set, the convention file is ignored; when not set, Pester dot-sources a 'Pester.BeforeContainer.ps1' from the repository root (Run.RepoRoot) if one is present. Type: scriptblock[] Default value: @() ParallelThrottleLimit: EXPERIMENTAL: Maximum number of test files to run at the same time when Run.Parallel is enabled, passed through to 'ForEach-Object -Parallel -ThrottleLimit'. The default 0 uses all available processors ([Environment]::ProcessorCount). Set a lower number to cap how many runspaces run concurrently. Only used when Run.Parallel is enabled. Type: int Default value: 0 SkipRemainingOnFailure: Skips remaining tests after failure for selected scope, options are None, Run, Container and Block. Type: string Default value: 'None' FailOnNullOrEmptyForEach: Fails discovery when -ForEach is provided $null or @() in a block or test. Can be overridden for a specific Describe/Context/It using -AllowNullOrEmptyForEach. Type: bool Default value: $true RepoRoot: Root directory of the repository. Found by searching for the .git directory recursively. When not found, the current working directory is used. Type: string Default value: '<path of .git>' Filter: Tag: Tags of Describe, Context or It to be run. Type: string[] Default value: @() ExcludeTag: Tags of Describe, Context or It to be excluded from the run. Type: string[] Default value: @() Line: Filter by file and scriptblock start line, useful to run parsed tests programmatically to avoid problems with expanded names. Explicit filter that overrides -Skip. Example: 'C:\tests\file1.Tests.ps1:37' Type: string[] Default value: @() ExcludeLine: Exclude by file and scriptblock start line, takes precedence over Line. Type: string[] Default value: @() FullName: Full name of test with -like wildcards, joined by dot. Example: '*.describe Get-Item.test1' Type: string[] Default value: @() CodeCoverage: Enabled: Enable CodeCoverage. Type: bool Default value: $false OutputFormat: Format to use for code coverage report. Possible values: JaCoCo, Cobertura Type: string Default value: 'JaCoCo' OutputPath: Path relative to the current directory where code coverage report is saved. Type: string Default value: 'coverage.xml' OutputEncoding: Encoding of the output file. Type: string Default value: 'UTF8' Path: Directories or files to be used for code coverage, by default the Path(s) from general settings are used, unless overridden here. Type: string[] Default value: @() ExcludeTests: Exclude tests from code coverage. This uses the TestFilter from general configuration. Type: bool Default value: $true RecursePaths: Will recurse through directories in the Path option. Type: bool Default value: $true CoveragePercentTarget: Target percent of code coverage that you want to achieve, default 75%. Type: decimal Default value: 75 UseBreakpoints: When false, use Profiler based tracer to do CodeCoverage instead of using breakpoints. Type: bool Default value: $false SingleHitBreakpoints: Remove breakpoint when it is hit. This increases performance of breakpoint based CodeCoverage. Type: bool Default value: $true ReportRoot: Root path for the code coverage report. Uses Run.RepoRoot by default. Type: string Default value: $null TestResult: Enabled: Enable TestResult. Type: bool Default value: $false OutputFormat: Format to use for test result report. Possible values: NUnitXml, NUnit2.5, NUnit3 or JUnitXml Type: string Default value: 'NUnitXml' OutputPath: Path relative to the current directory where test result report is saved. Type: string Default value: 'testResults.xml' OutputEncoding: Encoding of the output file. Type: string Default value: 'UTF8' TestSuiteName: Set the name assigned to the root 'test-suite' element. Type: string Default value: 'Pester' Should: ErrorAction: Controls if Should throws on error. Use 'Stop' to throw on error, or 'Continue' to fail at the end of the test. Type: string Default value: 'Stop' DisableV5: Disables usage of Should -Be assertions, that are replaced by Should-Be in version 6. Type: bool Default value: $false Debug: ShowFullErrors: Show full errors including Pester internal stack. This property is deprecated, and if set to true it will override Output.StackTraceVerbosity to 'Full'. Type: bool Default value: $false WriteDebugMessages: Write Debug messages to screen. Type: bool Default value: $false WriteDebugMessagesFrom: Write Debug messages from a given source, WriteDebugMessages must be set to true for this to work. You can use like wildcards to get messages from multiple sources, as well as * to get everything. Type: string[] Default value: @('Discovery', 'Skip', 'Mock', 'CodeCoverage') ShowNavigationMarkers: Write paths after every block and test, for easy navigation in VSCode. Type: bool Default value: $false ShowStartMarkers: Write an indication when each test starts. Type: bool Default value: $false ReturnRawResultObject: Returns unfiltered result object, this is for development only. Do not rely on this object for additional properties, non-public properties will be renamed without previous notice. Type: bool Default value: $false Output: Verbosity: The verbosity of output, options are None, Normal, Detailed and Diagnostic. Type: string Default value: 'Normal' StackTraceVerbosity: The verbosity of stacktrace output, options are None, FirstLine, Filtered and Full. Type: string Default value: 'Filtered' CIFormat: The CI format of error output in build logs, options are None, Auto, AzureDevops and GithubActions. Type: string Default value: 'Auto' CILogLevel: The CI log level in build logs, options are Error and Warning. Type: string Default value: 'Error' RenderMode: The mode used to render console output, options are Auto, Ansi, ConsoleColor and Plaintext. Type: string Default value: 'Auto' TestDrive: Enabled: Enable TestDrive. Type: bool Default value: $true TestRegistry: Enabled: Enable TestRegistry. Type: bool Default value: $true SEE ALSO Pester website: https://pester.dev New-PesterConfiguration Invoke-Pester |