Skip to content

New SamplerJaCoCoDocument

gaelcolas edited this page Jul 18, 2024 · 1 revision

New-SamplerJaCoCoDocument

SYNOPSIS

Creates a new JaCoCo XML document based on the provided missed and hit lines.

SYNTAX

New-SamplerJaCoCoDocument [-MissedCommands] <Object[]> [-HitCommands] <Object[]> [-PackageName] <String>
 [[-PackageDisplayName] <String>] [<CommonParameters>]

DESCRIPTION

Creates a new JaCoCo XML document based on the provided missed and hit lines. This command is usually used together with the output object from Pester that also have been passed through ModuleBuilder's Convert-LineNumber.

EXAMPLES

EXAMPLE 1

$pesterObject = Invoke-Pester ./tests/unit -CodeCoverage
$pesterObject.CodeCoverage.MissedCommands |
    Convert-LineNumber -ErrorAction 'Stop' -PassThru | Out-Null
$pesterObject.CodeCoverage.HitCommands |
    Convert-LineNumber -ErrorAction 'Stop' -PassThru | Out-Null
New-SamplerJaCoCoDocument `
    -MissedCommands $pesterObject.CodeCoverage.MissedCommands `
    -HitCommands $pesterObject.CodeCoverage.HitCommands `
    -PackageName 'source'

EXAMPLE 2

New-SamplerJaCoCoDocument `
    -MissedCommands @{
        Class            = 'ResourceBase'
        Function         = 'Compare'
        HitCount         = 0
        SourceFile       = '.\Classes\001.ResourceBase.ps1'
        SourceLineNumber = 4
    } `
    -HitCommands @{
        Class            = 'ResourceBase'
        Function         = 'Compare'
        HitCount         = 2
        SourceFile       = '.\Classes\001.ResourceBase.ps1'
        SourceLineNumber = 3
    } `
    -PackageName 'source'

PARAMETERS

-HitCommands

An array of PSCustomObject that contain all the code lines that were hit.

Type: Object[]
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-MissedCommands

An array of PSCustomObject that contain all the missed code lines.

Type: Object[]
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PackageDisplayName

The display name of the package if it should be shown to the user differently, e.g. 'source' if the package name is '2.3.0'. Defaults to the same value as PackageName.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PackageName

The name of package of the test source files, e.g. 'source', 'MyFunction', or '2.3.0'.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

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

System.Xml.XmlDocument

NOTES

RELATED LINKS

Clone this wiki locally