Modules/businessdev.ALbuild.Apps/Private/Test-BcIsTestApp.ps1

function Test-BcIsTestApp {
    <#
    .SYNOPSIS
        Determines whether an AL app is a test app.
 
    .DESCRIPTION
        Internal, pure-ish helper (reads AL source only when the manifest is inconclusive). An app
        is a test app when its manifest declares the "test" framework reference, depends on a
        Microsoft test/assert library, or its AL source defines an object with "Subtype = Test".
 
    .PARAMETER Manifest
        The parsed app.json manifest object.
 
    .PARAMETER AppFolder
        The app folder, used to scan AL source as a fallback.
 
    .OUTPUTS
        System.Boolean.
    #>

    [CmdletBinding()]
    [OutputType([bool])]
    param(
        [Parameter(Mandatory)] [PSCustomObject] $Manifest,
        [Parameter(Mandatory)] [string] $AppFolder
    )

    if (($Manifest.PSObject.Properties.Name -contains 'test') -and $Manifest.test) {
        return $true
    }

    if ($Manifest.PSObject.Properties.Name -contains 'dependencies') {
        foreach ($dependency in @($Manifest.dependencies)) {
            if ("$($dependency.publisher)" -eq 'Microsoft' -and
                ("$($dependency.name)" -like '*assert*' -or "$($dependency.name)" -like '*test*')) {
                return $true
            }
        }
    }

    foreach ($alFile in (Get-ChildItem -LiteralPath $AppFolder -Filter '*.al' -Recurse -File -ErrorAction SilentlyContinue)) {
        $content = Get-Content -LiteralPath $alFile.FullName -Raw -ErrorAction SilentlyContinue
        if ($content -match '(?im)^\s*Subtype\s*=\s*Test\s*;') {
            return $true
        }
    }

    return $false
}