如何运行在执行所有功能文件/步骤后执行 S3 上传的命令?

问题描述 投票:0回答:1

我目前正在使用以下方法执行一些基本性能测试:

STATUS:例如,performanceTotal 包会生成 csv 和 json 结果文件,我在其中提取信息以生成一个图表,用于测量更改页面所需的时间。结果文件仅在执行所有功能/步骤(包括 AfterAll)后生成。

ISSUE:为了生成包含我感兴趣的结果的长期图表,我计划在 Jenkins 中运行测试,但我需要将结果文件上传到 S3(上传请求成功!),并且由于测试结果文件仅在执行结束时可用,有没有办法在“外部”或运行结束后执行上传命令?

这里是 AfterAll 步骤的片段,其中 feat 是我正在测试的功能的数组,item 是数组中的对象/功能,用于生成单独的图。例如,功能可能包含:[登录、注销、NavigationToPage_X 等]。 result 是一个 JSON,其中包含从用于图形生成的结果文件中提取的信息。

AfterAll({timeout: 10 * 60000} ,async () => {
  logInfo("Starting generation of charts and upload of json result files to S3");
  await Promise.all(feat.map(async item => {
    await generatePerformanceChart(item, "line", result);
    await uploadResultsToS3(item);
  }));
  logSuccess("Upload of results files to S3 successful!");
});

但这不起作用,因为由于某种原因结果文件是在 AfterAll 步骤之后生成的。我需要一些在 Cucumber 框架之外执行上传命令的东西。

javascript typescript jenkins-pipeline webdriver-io cucumberjs
1个回答
0
投票

看起来您正在步骤定义内的

AfterAll
下运行它?您需要的是使用
onComplete
下的
wdio.conf.js
挂钩。来自WebdriverIO 文档

/**
 * Gets executed after all workers have shut down and the process is about to exit.
 * An error thrown in the `onComplete` hook will result in the test run failing.
 * @param {object} exitCode 0 - success, 1 - fail
 * @param {object} config wdio configuration object
 * @param {Array.<Object>} capabilities list of capabilities details
 * @param {<Object>} results object containing test results
 */
onComplete: function (exitCode, config, capabilities, results) {
},
© www.soinside.com 2019 - 2024. All rights reserved.