Modules/businessdev.ALbuild.Apps/Private/Get-BcAlTestProcedure.ps1
|
function Get-BcAlTestProcedure { <# .SYNOPSIS Enumerates the [Test] procedures in AL sources and returns their statement lines. .DESCRIPTION The [Test] view of Get-BcAlProcedure, behind Get-BcTestQuality and Test-BcTestAssertion, so both see the same set of tests and the same bodies and can only differ in the verdict they draw. For every procedure that carries a [Test] attribute it returns the declaring codeunit, the procedure name, its location, the ALbuild directives that apply to it and the executable statement lines of its body (comments stripped, block keywords and the surrounding begin/end removed). .PARAMETER WorkspaceRoot AL source root to scan; tooling folders (.alpackages, output, .git, node_modules, ...) are skipped. .PARAMETER Path A single .al file to scan instead of a whole workspace. .OUTPUTS PSCustomObject per test: Codeunit, TestName, FilePath, Line, Statements[], Directives[]. #> [CmdletBinding(DefaultParameterSetName = 'Workspace')] [OutputType([PSCustomObject])] param( [Parameter(Mandatory, ParameterSetName = 'Workspace')] [ValidateNotNullOrEmpty()] [string] $WorkspaceRoot, [Parameter(Mandatory, ParameterSetName = 'File')] [ValidateNotNullOrEmpty()] [string] $Path ) # -TestsOnly: the other bodies are parsed either way, they are simply not kept. A caller that needs # them (helper resolution) asks Get-BcAlProcedure directly. $scan = @{ TestsOnly = $true } if ($PSCmdlet.ParameterSetName -eq 'File') { $scan['Path'] = $Path } else { $scan['WorkspaceRoot'] = $WorkspaceRoot } return @(Get-BcAlProcedure @scan) } |