You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins任务执行完所有单元测试后异常终止,求排查思路

Jenkins已完成所有单元测试的执行,但最终输出中出现如下信息:
……
Passed test_name……
Closing app with package full name 'app_full_name'.
The active test run was aborted. Reason: One or more errors occurred.
Closing app with package full name 'app_full_name'
……

Hey there, let's break down how to troubleshoot this frustrating issue—your Jenkins-run UWP unit tests are passing all cases but still aborting at the end with that vague "one or more errors" message. Your hunch about the app UI window not closing is a solid starting point, but let's cover all actionable angles to get to the root cause:

Troubleshooting Steps
  • Dig into full, verbose Jenkins logs
    The snippet you shared only shows a small slice of what's happening. Enable verbose logging for your Jenkins job (check the job configuration's "Log Level" settings) to capture every detail leading up to the abort. Specifically look for:

    • Hidden error messages or stack traces right before the "active test run was aborted" line
    • Timestamps around the app closing attempts to spot delays or hangs
    • Any warnings about UWP package termination failures from the test runner
  • Add detailed logging to your UWP test app's cleanup logic
    Most UWP test frameworks let you inject custom logging into teardown methods. Add logs to confirm:

    • When the test Teardown method starts and finishes
    • Whether calls like Application.Current.Exit() or Window.Close() execute without exceptions
    • If there are unhandled exceptions in the app's main UI thread that don't bubble up to the test runner
      Save these logs to your Jenkins workspace so you can review them post-build.
  • Verify your cleanup logic works locally first
    Test your UWP unit tests on your local machine (outside Jenkins) and manually check if the app window closes properly after all tests run. If it hangs locally too, the issue is with your test code, not Jenkins. Fix the cleanup logic first—make sure you explicitly close all opened windows, dispose of UI resources, and avoid relying on implicit garbage collection to shut down the app.

  • Check Jenkins agent permissions and session state
    Jenkins agents running as Windows services often lack interactive desktop access, which can break UWP app window management:

    • Try running the Jenkins agent as a local user with interactive desktop rights (instead of a service)
    • Ensure the agent user has permission to terminate UWP processes—test this by manually killing the app_full_name process via Task Manager as that user
    • Disable screen savers, power locks, or remote desktop disconnects on the agent machine, as these can interfere with UI window operations
  • Add a forced cleanup script to your Jenkins job
    As a test to confirm your window-closing theory, add a PowerShell step right after your test run to force-kill the UWP app:

    # Kill the UWP app by package name (replace with your actual package name)
    $appPackage = Get-AppxPackage *app_full_name*
    if ($appPackage) {
        Stop-Process -Name $appPackage.PackageFamilyName -Force -ErrorAction SilentlyContinue
        Write-Host "Forcibly terminated UWP app package: $($appPackage.Name)"
    }
    

    If the abort stops happening after adding this, it confirms the app wasn't closing on its own, and you can focus on fixing the test's native cleanup logic.

  • Update your UWP test framework and Jenkins plugins
    Older versions of the UWP Unit Test Framework (and corresponding Jenkins plugins) had known issues with test run cleanup when UI elements were involved. Make sure you're using the latest stable versions of both to rule out bugs that have already been fixed.


内容的提问来源于stack exchange,提问作者gmojunior

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:16:16