tag:help.appveyor.com,2012-11-13:/discussions/problems/739-test-script-fails-and-doesnt-move-forward-with-uploadAppVeyor: Discussion 2018-10-19T08:16:43Ztag:help.appveyor.com,2012-11-13:Comment/344370492014-09-03T15:15:20Z2014-09-03T15:15:21ZTest script fails and doesn't move forward with upload<div><p>From the docs, it says I can upload a script (<a href=
"http://www.appveyor.com/docs/running-tests">http://www.appveyor.com/docs/running-tests</a>)
with test results.</p>
<p>However, when running a script, if the tests fail, the whole
thing stops and nothing is uploaded:</p>
<p><a href=
"https://ci.appveyor.com/project/ferventcoder/chocolatey/build/1.0.17">
https://ci.appveyor.com/project/ferventcoder/chocolatey/build/1.0.17</a></p>
<p>Note that the script (set to powershell) contains:</p>
<pre>
<code>$chocoDir = $env:ChocolateyInstall
if(!$chocoDir){$chocoDir="$env:SystemDrive\chocolatey"}
$pesterDir = (dir $chocoDir\lib\Pester*)
if($pesterDir.length -gt 0) {$pesterDir = $pesterDir[-1]}
Write-Host "Pester is located at $pesterDir"
$args="."
Import-Module "$pesterDir\tools\Pester.psm1";
Invoke-Pester -OutputXml Test.xml -EnableExit $args
$testsPassed = $?
# http://stackoverflow.com/questions/10666035/powershell-difference-between-and-lastexitcode
# upload results to AppVeyor
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test.xml))
if (! $testsPassed) {
exit 1;
}</code>
</pre></div>ferventcodertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-03T16:43:55Z2014-09-03T16:43:55ZTest script fails and doesn't move forward with upload<div><p>I think this might have to do with setting -EnableExit <a href=
"http://help.appveyor.com/discussions/problems/558-setting-exit-code-to-powershell-script-does-not-work">
http://help.appveyor.com/discussions/problems/558-setting-exit-code...</a></p>
<p>That way the script can move forward.</p></div>ferventcodertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-03T18:01:05Z2014-09-03T18:01:05ZTest script fails and doesn't move forward with upload<div><p>Well, yeah, but in general I could see the issue with other
applications. I think more general and nicer solution to the
problem will be adding "On build complete script" section.</p>
<p>Will add that into today's update.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-04T04:01:06Z2014-09-04T04:01:06ZTest script fails and doesn't move forward with upload<div><p>Update deployed. There is a new "On build finish script" block
that runs before finishing build whether it's successful of
failed.</p>
<p>In <code>appveyor.yml</code> it's:</p>
<pre>
<code>on_finish:
- my script</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-04T12:19:14Z2014-09-04T12:19:14ZTest script fails and doesn't move forward with upload<div><p>I'm guessing this is not available in the UI yet.</p></div>ferventcodertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-04T12:20:12Z2014-09-04T12:20:49ZTest script fails and doesn't move forward with upload<div><p>Also, it would be wicked if I could finish setting up everything
in the UI and then export my settings as an appveyor.yml file. I'll
start a new discussion on that.</p></div>ferventcodertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-04T12:27:35Z2014-09-04T12:27:35ZTest script fails and doesn't move forward with upload<div><p>I see the on build finish in the UI, just want to verify that it
happens AFTER the test scripts have run? In the UI it's a bit
confusing as it looks like it happens earlier in the pipeline
(during the compile phase).</p></div>ferventcodertag:help.appveyor.com,2012-11-13:Comment/344370492014-09-04T12:42:06Z2014-09-04T12:42:06ZTest script fails and doesn't move forward with upload<div><p>It went in the correct order, so awesome!</p></div>ferventcoder