简体   繁体   English

剧作家 cucumber json 报告需要根据 package.Z466DEEC76ECDF3diff5FCA6D38 执行脚本5D6 生成不同的名称

[英]playwright cucumber json report need to generate with different names based on package.json execution scripts [ need diff report for each execution]

I am using playwright cucumber report.json我正在使用剧作家 cucumber 报告。json

This is my cucumber.js这是我的 cucumber.js 在此处输入图像描述

My package.json我的 package.json

"test:sit1rcb": "NODE_ENV=sit1 NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js -t @RCBSIT features/RCB/*.feature",
"test:sit3rcb": "NODE_ENV=sit3 NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js -t @RCBSIT features/RCB/*.feature",
"test:sit3csk": "NODE_ENV=sit3 NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js -t @CSKSIT features/CSK/*.feature",
"test:sit3kkr": "NODE_ENV=sit3 NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js -t @KKRSIT features/KKR/*.feature"

each script should generate a different report based on names ( RCB, CSK, KKR) say like CSK_report.json, RCB_report.json...每个脚本应根据名称(RCB、CSK、KKR)生成不同的报告,例如 CSK_report.json、RCB_report.json...

my report path我的报告路径

在此处输入图像描述

When we execute this in windows server pipleline report is created and placed in a single location with the same file name.当我们在 windows 中执行此操作时,将创建服务器管道报告并将其放置在具有相同文件名的单个位置。 This means that whenever the test scripts are executed in same time for RCB, CSK, KKR in each(SIT1, SIT2) environment, the output will be overwritten and only the last executed test case result will be available for consumption这意味着,每当在每个(SIT1,SIT2)环境中同时执行 RCB、CSK、KKR 的测试脚本时,output 将被覆盖,只有最后执行的测试用例结果可供使用

Please help me on following请帮助我关注

  1. How to rename the report.json based on package.json execution script, how to pass application pramameter to rename the report.json如何重命名报告。json 基于 package.jsonECDF 执行脚本,如何通过应用程序参数重命名报告。
  2. OR we need to generate 3 different report in 3 folder based on application name which passing from package.json script how to change the cucumber.js config to generate multiple report in different folder and pass the report path for each execution with application name in it?或者我们需要根据从 package.json 脚本传递的应用程序名称在 3 个文件夹中生成 3 个不同的报告 如何更改 cucumber.js 脚本如何更改 cucumber.js 路径配置中的每个应用程序以在不同的文件夹中使用报告配置生成多个报告?

I am expecting to see我期待看到

CSK_report_SIT3.json for npm run test:sit3csk
RCB_report_SIT3.json for npm run test:sit3rcb

please help me on this.请帮助我。

You can pass report file name from the test script of package.json file.您可以从 package.json 文件的测试脚本中传递报告文件名。

Create multiple const's in cucumber.js file for different names like CSK, KKR and RCB because you be will running different features files.在 cucumber.js 文件中为 CSK、KKR 和 RCB 等不同名称创建多个 const,因为您将运行不同的功能文件。 Pass the REPORT_FILE_NAME from the package.json script, this will be passed to cucumber.js file and create report file accordingly.从 package.json 脚本传递 REPORT_FILE_NAME,这将传递给 cucumber.js 文件并相应地创建报告文件。 Also, will create unique file name and won't override.此外,将创建唯一的文件名并且不会覆盖。

Check below sample code.检查下面的示例代码。

cucumber.js cucumber.js

    const csk_test= `
   --require config/config.js 
  --require setup/assertions.js 
  --require setup/hooks.js 
  --require tests/sb/base-setup/baseSetup.js
  --require tests/sb/step-definitions/features/csk/**/*.js
   --format json:./reports/${process.env.REPORT_FILE_NAME}.json
  --format summary --format @cucumber/pretty-formatter 
  --no-strict 
  --tags "@CSK"
  --publish-quiet"
  },
  `;

    const rcb_test= `
   --require config/config.js 
  --require setup/assertions.js 
  --require setup/hooks.js 
  --require tests/sb/base-setup/baseSetup.js
  --require tests/sb/step-definitions/features/rcb/**/*.js
   --format json:./reports/${process.env.REPORT_FILE_NAME}.json
  --format summary --format @cucumber/pretty-formatter 
  --no-strict 
  --tags "@RCB"
  --publish-quiet"
  },
  `;

package.json package.json

"test:sb:csk": "cross-env BROWSER='' HEADLESS=false LANGUAGE=english REPORT_FILE_NAME=CSK_Test_Report APP_LOAD_TIMEOUT=50000 --retry 3 cucumber-js --parallel 2 -p csk_test",

"test:sb:rcb": "cross-env BROWSER='' HEADLESS=false LANGUAGE=english REPORT_FILE_NAME=RCB_Test_Report APP_LOAD_TIMEOUT=50000 --retry 3 cucumber-js --parallel 2 -p rcb_test",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM