Closed GreatScott000 closed 4 years ago
the error is because it doesn't find and run the tests - so the test results.xml didn't get created. How does the run-tests.ps1 look?
Run-Tests.ps1 is unchanged from the original. I have extracted out the logic and the Get-TestsInNavContainer does not return any tests unless the DEFAULT Test Suite is populated BEFORE.
I extracted this code from Run-Tests.ps1 (to run in against another container) just to see what was happening and the $tests variable is null UNLESS I add something to DEFAULT Test Suite.
Why does Get-TestInNavContainer not find any tests?
$userName = 'admin'
$password = 'P@ssword1'
$containerName = 'Test-BC1401'
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object PSCredential -ArgumentList $userName, $SecurePassword
$testSuite = "DEFAULT"
$tests = Get-TestsFromBCContainer `
-containerName $containerName `
-credential $credential `
-ignoreGroups `
-testSuite $testSuite -debugMode
$tests
Output - does not find any tests.
Importing Objects from C:\ProgramData\NavContainerHelper\Extensions\Test-BC1401\PsTestTool-6\PSTestToolPage.fob (container path) Objects successfully imported Get-Tests, open page 130409 Index: 0, Offset: 0, Count: 2 Row - lineType = 0, run = True, CodeunitId = 0, codeunitName = '', name = '' Index: 1, Offset: 0, Count: 2 Row - lineType = 0, run = True, CodeunitId = , codeunitName = '', name = '' Index: 2, Offset: 0, Count: 2 Scroll Index: 2, Offset: 0, Count: 2 Breaking - rowIndex: 2
in BC14 you need to populate the test suite in code like described here: https://freddysblog.com/2019/04/13/running-tests-in-containers/ else the test suite will be empty. In BC15 and later you can specify an extension id, which will be added automatically.
Thank you for the information. I was unaware of the BC14 information but thought there must be something different.
This has resolved my issue.
Describe the issue I am debugging issues I am having with the CI.YML in the https://dev.azure.com/businesscentralapps/HelloWorld repository as I make adjustments for BC14 I have published the APP and TEST apps to a container outside the build pipeline to test and unless I manually add scripts to the DEFAULT Test Suite no tests are found by Get-TestsInNavContainer
Is Get-TestsInNAVContainer supposed to add the tests to the Test Suite?
How can I get this work? Am I missing something in the CI.YML? Is there a step that adds the tests to the Test Suite?
Without the tests being found, the pipeline fails as the TempTestResultFile is not created and then the Run-Tests script errors out. You will note the output from the pipeline matches the output from the Get-Tests scripts when no test added to the default container as opposed to the Get-Test script output when the tests are added to the Default Test Suite manually.
I have run this against the BC16 (in my training class from Kevin Smet) and it works as expected. So I am wondering if it is a BC14 issue.
Scripts used to create container and cause the issue Script to build container
Script to get tests
Full output of scripts Script output for Create-BCContainer script
Output from Get-Tests script without tests added to DEFAULT Test Suite
Output from Get-Tests script with tests added to DEFAULT Test Suite
Screenshots Test is installed and available
Tests added to DEFAULT Test Suite
Error in Run-Tests.ps1 from Pipeline
Additional context