设置Cypress并行运行
修改.circleci文件夹下的config.yml文件,在working_directory:~/app下增加parallelism:2配置项,同时更改package.json文件,加入--parallel参数
"scripts":{
"cy:run":"yarn cypress run",
"debug":"yarn cypress open",
"start":"node server.js",
"test":"START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3002 cy:run"
"cy:run":"cypress run --record --key cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --parallel"
然后提交到Github,再次执行测试,在Dashboard上便可以查看到并行执行的结果
Cypress还提供了分组功能,通过加标签的形式,多次运行后便可以通过标签在Dashboard中进行分组筛选,语法很简单,在运行中添加参数--group即可
//将login模块的所有用例分为Login组
cypress run --record --group Login --spec 'cypress/integration/login//*.js'
也可以通过配置文件进行分组设置,修改package.json文件
"scripts":{
"ModuleRun":"node moduleRunIndex.js",
"debug":"yarn cypress open",
"start":"node server.js",
"test":"START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3002 cy-run",
"cy-run":"yarn cy:run1 && yarn cy:run2",
"cy:run1":"yarn cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --group group1 --spec \"cypress/integration/first-spec.js\" --parallel",
"cy:run2":"yarn cypress run --record --key a5004313-38e2-4b57-b0f6-2f7eda0c2b79 --group group2 --spec \"cypress/integration/third-spec.js\" --parallel",
然后在Dashboard中便是如下结果
![自动化测试框架[Cypress持续集成之Circle CI]_Circle集成Github_20](https://s2.51cto.com/images/blog/202107/09/b8bccef9dae0cc24fd88e36e0d32a14f.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=/resize,m_fixed,w_1184)