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

Jenkins分布式API测试插件咨询:支持Agent/无Agent模式及TestNG执行

Jenkins Plugins for Distributed API Testing with TestNG .class Files

Perfect question—let’s walk through the Jenkins plugins and workflows that will let you distribute your TestNG-based API tests (using your .class files) across Slaves/Agents, plus support both agent and agent-less modes:

1. Jenkins Pipeline + TestNG Plugin

This is the most flexible, widely used approach that checks all your boxes:

  • Agent Mode: Use the agent directive in your Pipeline script to target specific Slave nodes. You’ll first stash your compiled .class files (and any dependencies like TestNG JARs) in the Master, then unstash them on the Slave to run the tests locally. Here’s a quick snippet to illustrate:
    pipeline {
        agent { label 'api-test-slave' } // Target a dedicated Slave agent
        stages {
            stage('Prepare Test Files') {
                steps {
                    stash includes: 'test-classes/**/*.class, lib/**/*.jar', name: 'test-resources'
                }
            }
            stage('Run Distributed API Tests') {
                steps {
                    unstash 'test-resources'
                    sh 'java -cp "test-classes/:lib/*" org.testng.TestNG testng.xml'
                }
            }
            stage('Consolidate Results') {
                steps {
                    testng 'test-output/*.xml' // Auto-publish results back to Master
                }
            }
        }
    }
    
  • Agent-less Mode: If you don’t want to rely on fixed Slaves, use agent any (runs on any available node, including the Master) or agent none (with nested node blocks to execute tests on temporary nodes). The TestNG plugin automatically aggregates all results and surfaces them in the Master’s dashboard.

2. Distributed TestNG Plugin

Built specifically for scaling TestNG tests across Jenkins nodes, this plugin is tailor-made for your use case:

  • It splits your TestNG suite (using your .class files) across multiple Slave agents, parallelizing execution to speed up test runs.
  • Supports both dedicated Agent setups and dynamic node allocation (for your agent-less requirement).
  • All test results are consolidated on the Master, so you get a single unified report instead of scattered outputs from each Slave.
  • You can configure it via the Jenkins UI: just point it to your test classpath, TestNG XML suite, and select which nodes to distribute tests to.

3. Jenkins Swarm Plugin (for Ephemeral Agent-less Execution)

If you need on-demand, temporary workers (no pre-configured Agents required), the Swarm Plugin is your go-to:

  • You can spin up Swarm clients on any machine (they auto-connect to the Master), pull your .class files and dependencies, run the TestNG tests, and disconnect once done.
  • Pair this with the TestNG Plugin to collect all results back to the Master. This is ideal if you don’t want to maintain a fixed pool of Slaves.

Quick Tips for Your Workflow:

  • Always ensure your .class files and dependencies are properly transferred to the target node (via stash/unstash, or a shared file system) before running tests.
  • All these tools handle result aggregation automatically, so you won’t have to manually collect reports from each Slave.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:15:22