Invoke-Gherkin
SYNOPSIS
Invokes Pester to run all tests defined in .feature files
SYNTAX
Default (Default)
RetestFailed
DESCRIPTION
Upon calling Invoke-Gherkin, all files that have a name matching *.feature in the current folder (and child folders recursively), will be parsed and executed.
If ScenarioName is specified, only scenarios which match the provided name(s) will be run. If FailedLast is specified, only scenarios which failed the previous run will be re-executed.
Optionally, Pester can generate a report of how much code is covered by the tests, and information about any commands which were not executed.
EXAMPLES
EXAMPLE 1
This will find all *.feature specifications and execute their tests. No exit code will be returned and no log file will be saved.
EXAMPLE 2
This will run all *.feature specifications under ./Tests that begin with Utils.
EXAMPLE 3
This will only run the Scenario named "Add Numbers"
EXAMPLE 4
This runs all tests from the current directory downwards and writes the results according to the NUnit schema to artifacts/TestResults.xml just below the current directory. The test run will return an exit code equal to the number of test failures.
EXAMPLE 5
Runs all *.feature specifications in the current directory, and generates a coverage report for all commands in the "ScriptUnderTest.ps1" file.
EXAMPLE 6
Runs all *.feature specifications in the current directory, and generates a coverage report for all commands in the "FunctionUnderTest" function in the "ScriptUnderTest.ps1" file.
EXAMPLE 7
Runs all *.feature specifications in the current directory, and generates a coverage report for all commands on lines 10 through 20 in the "ScriptUnderTest.ps1" file.
PARAMETERS
-FailedLast
Rerun only the scenarios which failed last time
-Path
This parameter indicates which feature files should be tested.
Aliased to 'Script' for compatibility with Pester, but does not support hashtables, since feature files don't take parameters.
-ScenarioName
When set, invokes testing of scenarios which match this name.
Aliased to 'Name' and 'TestName' for compatibility with Pester.
-EnableExit
Will cause Invoke-Gherkin to exit with a exit code equal to the number of failed tests once all tests have been run. Use this to "fail" a build when any tests fail.
-Tag
Filters Scenarios and Features and runs only the ones tagged with the specified tags.
-ExcludeTag
Informs Invoke-Gherkin to not run blocks tagged with the tags specified.
-CodeCoverage
Instructs Pester to generate a code coverage report in addition to running tests. You may pass either hashtables or strings to this parameter.
If strings are used, they must be paths (wildcards allowed) to source files, and all commands in the files are analyzed for code coverage.
By passing hashtables instead, you can limit the analysis to specific lines or functions within a file. Hashtables must contain a Path key (which can be abbreviated to just "P"), and may contain Function (or "F"), StartLine (or "S"), and EndLine ("E") keys to narrow down the commands to be analyzed. If Function is specified, StartLine and EndLine are ignored.
If only StartLine is defined, the entire script file starting with StartLine is analyzed. If only EndLine is present, all lines in the script file up to and including EndLine are analyzed.
Both Function and Path (as well as simple strings passed instead of hashtables) may contain wildcards.
-Strict
Makes Pending and Skipped tests to Failed tests. Useful for continuous integration where you need to make sure all tests passed.
-OutputFile
The path to write a report file to. If this path is not provided, no log will be generated.
-OutputFormat
The format for output (LegacyNUnitXml or NUnitXml), defaults to NUnitXml
-Quiet
Disables the output Pester writes to screen. No other output is generated unless you specify PassThru, or one of the Output parameters.
-PesterOption
Sets advanced options for the test execution. Enter a PesterOption object, such as one that you create by using the New-PesterOption cmdlet, or a hash table in which the keys are option names and the values are option values. For more information on the options available, see the help for New-PesterOption.
-Show
Customizes the output Pester writes to the screen. Available options are None, Default, Passed, Failed, Pending, Skipped, Inconclusive, Describe, Context, Summary, Header, All, Fails.
The options can be combined to define presets. Common use cases are:
None - to write no output to the screen. All - to write all available information (this is default option). Fails - to write everything except Passed (but including Describes etc.).
A common setting is also Failed, Summary, to write only failed tests and test summary.
This parameter does not affect the PassThru custom object or the XML output that is written when you use the Output parameters.
-PassThru
Returns a custom object (PSCustomObject) that contains the test results. By default, Invoke-Gherkin writes to the host program, not to the output stream (stdout). If you try to save the result in a variable, the variable is empty unless you use the PassThru parameter. To suppress the host output, use the Quiet parameter.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
NOTES
RELATED LINKS
https://pester.dev/docs/v4/commands/Invoke-Pester
https://kevinmarquette.github.io/2017-04-30-Powershell-Gherkin-advanced-features/
EDIT THIS PAGE
This page was auto-generated using Pester's comment based help. To edit the content of this page, change the corresponding help in the pester/Pester repository. See our contribution guide for more information.