I am working with PowerShell which doesn't seem to have an up-to-date language spec. This leaves me wondering about some edge cases. I've taken to testing my assumptions about how PowerShell's runtime behaves. Here is a concrete example:
It 'the System.Exception that is thrown is actually a ParameterBindingException.' {
$o = New-Object psobject -Property @{a=1}
$o.a | Should be 1
try
{
$o | f
}
catch [System.Exception]
{
$threw = $true
$_.Exception.Message | Should match 'The input object cannot be bound because it did not contain the information required to bind all mandatory parameters: b'
$_.CategoryInfo.Reason | Should be 'ParameterBindingException'
$_.Exception -is [System.Management.Automation.ParameterBindingException] | Should be $true
}
$threw | Should be $true
}
That test asserts part of PowerShell Version 2.0's quirky exception catching behavior. (Evidently PS V2 throws ParameterBindingException
that can be caught as Exeception
but not ParameterBindingException
.)
This kind of test doesn't seem to fit any definition of "Unit Test" or "Integration Test" I have found. It tests the environment that code is executing in rather than the code itself.
I've spent some time searching for a name for this kind of testing but it seems like I'm just not using the key words. Is there a generally-accepted term whose definition matches this kind of test?