jimmymcp / al-test-runner

VS Code Extension to help run AL tests against Business Central container
https://jpearson.blog/al-test-runner-for-visual-studio-code/
MIT License
12 stars 16 forks source link

Install Test Runner Service: support for VSC workspaces (launch config) #130

Open christianbraeunlich opened 8 months ago

christianbraeunlich commented 8 months ago

Hello there,

when trying to install the Test Runner Service from within a vscode workspace via vscode command AL Test Runner: Install Test Runner Service it throws an error.

Used sample project structure:

root
├── app
|   ├── .alpackages
|   ├── src
|   └── app.json
├── test
|   ├── .alpackages
|   ├── src
|   └── app.json
├── README.md
└── testproject.code-workspace

Error message:

PS C:\Users\notebook\Documents\AL\ALProject4\test> if ($null -eq (Get-Module ALTestRunner)) {Import-Module "c:\Users\notebook\.vscode\extensions\jamespearson.al-test-runner-10.10.10\PowerShell\ALTestRunner.psm1" -DisableNameChecking}
PS C:\Users\notebook\Documents\AL\ALProject4\test> Install-TestRunnerService -LaunchConfig 'undefined'
Get-Content : Der Pfad "C:\Users\notebook\Documents\AL\ALProject4\test\.vscode\launch.json" kann nicht 
gefunden werden, da er nicht vorhanden ist.
In C:\Users\notebook\.vscode\extensions\jamespearson.al-test-runner-0.10.3\PowerShell\Select-ALTestRunnerCo 
nfig.ps1:7 Zeichen:37
+     $LaunchJson = ConvertFrom-Json (Get-Content $LaunchJsonPath -Raw)
+                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\notebook\launch.json:String) [Get-Content], ItemN  
   otFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

ConvertFrom-Json : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.     
In C:\Users\notebook\.vscode\extensions\jamespearson.al-test-runner-0.10.3\PowerShell\Select-ALTestRunnerCo 
nfig.ps1:7 Zeichen:36
+     $LaunchJson = ConvertFrom-Json (Get-Content $LaunchJsonPath -Raw)
+                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.Co  
   nvertFromJsonCommand

Please enter the name of the launch configuration to use in the AL Test Runner config file.
In C:\Users\notebook\.vscode\extensions\jamespearson.al-test-runner-0.10.3\PowerShell\Select-ALTestRunnerCo 
nfig.ps1:14 Zeichen:9
+         throw "Please enter the name of the launch configuration to u ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Please enter th...er config file.:String) [], RuntimeExcepti  
   on
    + FullyQualifiedErrorId : Please enter the name of the launch configuration to use in the AL Test Runner   
   config file.

Would it be possible to extend the Install Test Runner Service command by support for VSC workspaces (related to #79) as well?

Thanks in advance /Christian

jimmymcp commented 3 weeks ago

Sorry, getting round to looking at some old open issues today. Is this still a problem? In your example it looks like VS Code couldn't find any launch settings for the test folder. The extension uses the VS Code API for this which should look in the folder/workspace settings/user settings to retrieve launch settings.

Maybe this doesn't work well if you haven't already selected a launch config to use with the extension? You are prompted to do that when you are running a test and haven't already selected a launch profile, but maybe not when just installing the test runner service.