Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch Test Runner (InvokeMethodOnNull, PropertyNotFoundStrict) #85

Open
cegekaJG opened this issue Mar 21, 2023 · 2 comments

Comments

@cegekaJG
Copy link

I am unable to start the Test Runner, either through a single Test or an entire Test Codeunit. I encounter the following error:

PS C:\Cegeka Change Log.Test> if ($null -eq (Get-Module ALTestRunner)) {Import-Module "c:\.vscode\extensions\jamespearson.al-test-runner-0.8.3\PowerShell\ALTestRunner.psm1" -DisableNameChecking}
PS C:\Cegeka Change Log.Test>  
PS C:\Cegeka Change Log.Test> cd "c:\Cegeka Change Log.Test"
PS C:\Cegeka Change Log.Test> Invoke-ALTestRunner -Tests Test -ExtensionId "18ef0632-396e-4417-b441-ee883528e343" -ExtensionName "Cegeka Change Log.Test" -FileName "c:\Cegeka Change Log.Test\test\ChangelogActionTest.Codeunit.al" -SelectionStart 0 -LaunchConfig '{"type":"al","request":"launch","name":"Local Sandbox (changelog)","server":"http://changelog","serverInstance":"BC","port":7049,"tenant":"default","authentication":"UserPassword"}'
Importing module bccontainerhelper
BcContainerHelper version 4.0.14
BC.HelperFunctions emits usage statistics telemetry to Microsoft
You cannot call a method on a null-valued expression.
At C:\.vscode\extensions\jamespearson.al-test-runner-0.8.3\PowerShell\Get-ServerFromLaunchJson.ps1:13 char:9
+     if ($Server.Substring($Server.IndexOf('://') + 1).Contains(':'))  ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\.vscode\extensions\jamespearson.al-test-runner-0.8.3\PowerShell\Get-ServerFromLaunchJson.ps1:18 char:9
+         $Server = $Server.Substring($Server.IndexOf('://') + 3)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\.vscode\extensions\jamespearson.al-test-runner-0.8.3\PowerShell\Get-ServerFromLaunchJson.ps1:19 char:13
+         if ($Server.Substring($Server.length - 1) -eq '/') {
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

"docker inspect" requires at least 1 argument.
See 'docker inspect --help'.

Usage:  docker inspect [OPTIONS] NAME|ID [NAME|ID...]

Return low-level information on Docker objects
Get-BCContainerSharedFolders Telemetry Correlation Id: 01d3306b-9b98-4713-b209-f111049400a3
The property 'HostConfig' cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\bccontainerhelper\4.0.14\ContainerInfo\Get-NavContainerSharedFolders.ps1:27 char:9
+     if ($inspect.HostConfig.Binds) {
+         ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

PS C:\Cegeka Change Log.Test>      

Here is my .altestrunner/config.json:

{
    "containerResultPath":  "",
    "launchConfigName":  "Local Sandbox (changelog)",
    "securePassword":  "[Hash]",
    "userName":  "admin",
    "companyName":  "CRONUS AT",
    "testSuiteName":  "",
    "vmUserName":  "",
    "vmSecurePassword":  "",
    "remoteContainerName":  "",
    "dockerHost":  "",
    "newPSSessionOptions":  "",
    "testRunnerServiceUrl":  "http://:7048//ODataV4/TestRunner?company=CRONUS AT\u0026tenant=default",
    "codeCoveragePath":  ".//.altestrunner//codecoverage.json",
    "culture":  "en-US"
}

And here is my launch.json.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Changelog",
            "request": "launch",
            "type": "al",
            "environmentType": "OnPrem",
            "server": "http://changelog",
            "serverInstance": "BC",
            "authentication": "UserPassword",
            "breakOnError": true,
            "launchBrowser": true,
            "enableLongRunningSqlStatements": true,
            "enableSqlInformationDebugger": true,
            "tenant": "default"
        }
    ]
}
@jimmymcp
Copy link
Owner

The only things that I can notice:

  • you've got the new release from yesterday, has VS Code been restarted since then (I'm wondering if an old version of the PowerShell module is still imported into the session in the terminal
  • the name of the configuration in AL Test Runner config "Local Change (changelog)" does not match the name of the config in launch.json "Changelog". Update the name in the config file to match and try again

@cegekaJG
Copy link
Author

I didn't notice that the extension was using the launch settings of the main app, not the test app. I've reorganized the settings, deleted the config, updated AL Test Runner again and restarted VS Code. Here is launch.json from the main app:

{
    "version":  "0.2.0",
    "configurations":  [
        {
            "name":  "changelog",
            "type":  "al",
            "request":  "launch",
            "server":  "http://changelog",
            "serverInstance":  "BC",
            "port":  7049,
            "tenant":  "default",
            "authentication":  "UserPassword"
        },
        {
            "name":  "ll-bc-at",
            "type":  "al",
            "request":  "launch",
            "server":  "http://ll-bc-at",
            "serverInstance":  "BC",
            "port":  7049,
            "tenant":  "default",
            "authentication":  "Windows"
        }
    ]
}

And here is the config file for the extension:

{
    "containerResultPath":  "C:\\ProgramData\\BcContainerHelper",
    "launchConfigName":  "changelog",
    "securePassword":  "[Hash]",
    "userName":  "admin",
    "companyName":  "CRONUS AT",
    "testSuiteName":  "",
    "vmUserName":  "",
    "vmSecurePassword":  "",
    "remoteContainerName":  "",
    "dockerHost":  "",
    "newPSSessionOptions":  "",
    "testRunnerServiceUrl":  "",
    "codeCoveragePath":  ".//.altestrunner//codecoverage.json",
    "culture":  "en-US"
}

I no longer receive the error - however, it looks like it's still not working.

PS C:\CGK.ChangeLog\Cegeka Change Log.Test> if ($null -eq (Get-Module ALTestRunner)) {Import-Module "c:\Users\Jakob.Gillinger\.vscode\extensions\jamespearson.al-test-runner-0.8.4\PowerShell\ALTestRunner.psm1" -DisableNameChecking}
PS C:\CGK.ChangeLog\Cegeka Change Log.Test>  
PS C:\CGK.ChangeLog\Cegeka Change Log.Test> cd "c:\CGK.ChangeLog\Cegeka Change Log.Test"
PS C:\CGK.ChangeLog\Cegeka Change Log.Test> Invoke-ALTestRunner -Tests All -ExtensionId "18ef0632-396e-4417-b441-ee883528e343" -ExtensionName "Cegeka Change Log.Test" -LaunchConfig '{"name":"changelog","type":"al","request":"launch","server":"http://changelog","serverInstance":"BC","port":7049,"tenant":"default","authentication":"UserPassword"}'
Importing module bccontainerhelper
BcContainerHelper version 4.0.14
BC.HelperFunctions emits usage statistics telemetry to Microsoft
Running tests on changelog, company CRONUS AT, tenant default, extension Cegeka Change Log.Test, test runner 130450, culture en-US
Connecting to http://localhost:80/BC/cs?tenant=default&company=CRONUS%20AT
  Codeunit 78000 Changelog Action Test CCL Skipped
Copy from container changelog (C:\ProgramData\BcContainerHelper\38fc76b3-1efe-4105-8257-86be5e4ba65b.xml) to C:\CGK.ChangeLog\Cegeka Change Log.Test\.altestrunner\38fc76b3-1efe-4105-8257-86be5e4ba65b.xml
PS C:\CGK.ChangeLog\Cegeka Change Log.Test> 

It looks like it's connecting to localhost:80, which isn't a valid address, even though the settings should be connecting to changelog. Not sure where it is getting that from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants