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

Tests are running infinite #149

Closed jamesmayr closed 2 months ago

jamesmayr commented 2 months ago

I setup the test runner as you described in your blog. most things are working properly (test debugging, test running, creating test coverage json file)

But when I run tests, the Test-Suite in Visual Studio Code runs infinite. image

That means I cannot rerun all tests without restarting visual studio code and the test coverage summary is not displayed.

jimmymcp commented 2 months ago

do the test results get downloaded successfully? You should see a last.xml file in the .altestrunner folder. Are you using a multi-root workspace? If so, please check that the path to the folder has the same casing as the folder name in Windows Explorer - I've seen problems with the file watcher if not i.e.

if your folder structure is like this:

C:\MyApp

Then your workspace json file should have the path set to "App" and "Test" not "app" and "test". I assume this is some inherited Unix hang-up about case sensitive file paths. (Don't ask, I don't know).

jamesmayr commented 2 months ago

Thank that you took your time and thank you for your response.

Yes, we are using a multi-root workspace: image I've checked the paths and double checked that the path names are in the same case as the actual windows folder. (In the Workspace Config and In the alrunnerconfig aswell)

Yes, the result get downloaded. That's is how the folder looks like after the run:

image

Terminal Output:

PS C:\Projekte\DocumentViewer\test>
 *  History restored 

PS C:\Projekte\DocumentViewer\test> if ($null -eq (Get-Module ALTestRunner)) {Import-Module "c:\Users\Administrator\.vscode\extensions\jamespearson.al-test-runner-0.11.1\PowerShell\ALTestRunner.psm1" -DisableNameChecking}
PS C:\Projekte\DocumentViewer\test>
PS C:\Projekte\DocumentViewer\test> cd "c:\Projekte\DocumentViewer\test"
PS C:\Projekte\DocumentViewer\test> Invoke-ALTestRunner -Tests All -ExtensionId "152a896c-cff7-4720-b51b-555cb1b3c84b" -ExtensionName "Document Viewer_Test_App" -LaunchConfig '{"name":"Dev Server docker","request":"launch","type":"al","environmentType":"OnPrem","server":"http://test24jma/","serverInstance":"BC","authentication":"UserPassword","startupObjectId":70784578,"startupObjectType":"Page","breakOnError":true,"launchBrowser":true,"enableLongRunningSqlStatements":true,"enableSqlInformationDebugger":true,"tenant":"default"}' -GetCodeCoverage -GetPerformanceProfile
Importing module bccontainerhelper
BcContainerHelper version 6.0.19
WinRM service is not running, will not try to use WinRM sessions
BC.HelperFunctions emits usage statistics telemetry to Microsoft
Running on Windows, PowerShell 5.1.22621.3958
Running tests on test24jma, company CRONUS (Schweiz) AG, tenant default, extension Document Viewer_Test_App, test runner 130450, culture en-US
Connecting to http://localhost:80/BC/cs?tenant=default&company=CRONUS%20(Schweiz)%20AG
Setting test codeunit range ''
  Codeunit 78649 TestDocumentViewerIDAG Success (13.393 seconds)
    Testfunction CheckAppENU Success (13.393 seconds)
  Codeunit 78650 TestOCRService Success (4.616 seconds)
    Testfunction CheckMSOcrServiceFullTest Success (4.616 seconds)
  Codeunit 78651 TestPDFTextEnhancerIDAG Success (0.159 seconds)
    Testfunction CheckFixNumber Success (0.014 seconds)
    Testfunction CheckFixDatesEU Success (0.02 seconds)
    Testfunction CheckFixDatesUS Success (0.02 seconds)
    Testfunction CheckFindCurrency Success (0.014 seconds)
    Testfunction CheckFindLanguage Success (0.017 seconds)
    Testfunction CheckLineBreaks Success (0.014 seconds)
    Testfunction CheckRemoveSpecialCharacters Success (0.024 seconds)
    Testfunction CheckLinesAvaiable Success (0.036 seconds)
  Codeunit 78652 TestSwissQRIDAG Success (0.082 seconds)
    Testfunction SwissQrAvaiable Success (0.026 seconds)
    Testfunction CheckFixNumber Success (0.013 seconds)
    Testfunction CheckSwissQRScan Success (0.043 seconds)                                                                                                                                            Codeunit 78653 TestCopilotIDAG Skipped                                                                                                                                                             Codeunit 78654 ExternalStorageTest00DVIDAG Success (2.961 seconds)                                                                                                                                   Testfunction When_DataFromEmptyRecordAreRequested_Expect_NoErrorOccours Success (0.146 seconds)                                                                                                    Testfunction When_MediaIsRequestedFromLocalDatabase_Expect_MediaIsReturned Success (0.113 seconds)                                                                                             
    Testfunction When_MediaIsRequestedFromExternalStorage_Expect_MediaIsReturned Success (0.277 seconds)
    Testfunction When_MediaIsRequestedFromExternalStorageAndoLocalDatabase_Expect_MediaIsReturnedFromBothStorages Success (0.44 seconds)
    Testfunction When_MediaIsMovedToExternalStorage_Expect_MediaIsDeletedInLocalDatabaseAndAvailableInExternalStorage Success (0.197 seconds)
    Testfunction When_MediaSetIsRequested_Expect_MediaSetIsAvailableInExternalStorage Success (0.407 seconds)
    Testfunction When_BlobIsMovedToExternalStorage_Expect_BlobIsAvailableInExternalStorage Success (0.25 seconds)
    Testfunction When_BlobIsRequeted_Expect_BlobIsAvailableInLocalStorage Success (0.12 seconds)
    Testfunction When_MediaIsInLocalDatabase_Expect_FilemetadataAreAvailable Success (0.097 seconds)
    Testfunction When_MediaSetIsInLocalDatabase_Expect_FilemetadataAreAvailable Success (0.27 seconds)
    Testfunction When_MediaIsMovedToExternalStorage_Expect_FilemetadataIsStillAvailable Success (0.183 seconds)
    Testfunction When_MediaSetIsMovedToExternalStorage_Expect_FileMetadataAreStillAvailable Success (0.263 seconds)
    Testfunction When_BlobIsInLocalDatabase_Expect_FilemetadataAreAvailable Success (0.074 seconds)
    Testfunction When_BlobIsIsMovedToExternalStorage_Expect_FilemetadataAreAvailable Success (0.124 seconds)
Downloading code coverage to C:\temp\cc\codecoverage.json
Downloading performance profile to ./.altestrunner/PerformanceProfile.alcpuprofile
Copy from container test24jma (C:\ProgramData\BcContainerHelper\Extensions\test24jma\my\f1b9009c-565b-4b6c-b5b4-50b243e6d70b.xml) to C:\Projekte\DocumentViewer\test\.altestrunner\f1b9009c-565b-4b6c-b5b4-50b243e6d70b.xml
PS C:\Projekte\DocumentViewer\test> 

Important Note What i've found out that the f1b9009c-565b-4b6c-b5b4-50b243e6d70b.xml File is not copied. (I've checked both folders)

It seems that the run is almost finished, but not completely (after the terminal output) the Tests still runs (as reported before): image

jamesmayr commented 2 months ago

There was something with the absolute path in the config.json file that created the issue (i changed all codeCoveragePaths to relative paths and now it seems to work.)

thanks for pointing me in the right direction.

jimmymcp commented 2 months ago

Glad you got it working, thanks for the update 👍

wolframs commented 5 days ago

Hi @jimmymcp, sorry for the issue-necromancy, but I'm experiencing a very similar issue with the current version and a fresh BC25 container.

The tests run fully, the results are recognized (red/green), the terminal is ready to accept a new command, but the test runner in VSCode never stops. I have tried the hints above, to no avail.

Are there any known issues in the interactions with BC25?

Here's my config, for completeness:

{ "containerResultPath": "C:\\ProgramData\\BcContainerHelper\\Extensions\\w1bc25-test\\my", "launchConfigName": "Test - Recreate", "securePassword": "lalala", "userName": "admin", "companyName": "hi", "testSuiteName": "", "vmUserName": "", "vmSecurePassword": "", "remoteContainerName": "w1bc25-test", "dockerHost": "", "newPSSessionOptions": "", "testRunnerServiceUrl": "http://w1bc25-test:7047/BC/WS/hi/Codeunit/TestRunner?tenant=default", "codeCoveragePath": ".//.altestrunner//codecoverage.json", "culture": "en-US", "testRunnerCodeunitId": 71117472 }

jimmymcp commented 4 days ago

hey @wolframs,

issue-necromancy 🤣

I've found the most likely cause of this is that the filewatcher has failed to recognise that the results files have been downloaded and therefore that the tests have finished running.

Are you using a workspace file? If so, check that the casing of the paths in the file match the casing of the folders in Windows Explorer i.e. if the folder is called "App" on disk then the workspace file should have "App" in the path, not "app".

wolframs commented 12 hours ago

Hi @jimmymcp,

the casing is identical, but our extension structure is a bit more complicated, with two test extensions and one path pointing to a 2nd lvl subdirectory.

image

Does any of this look suspicious to you? ;)