为 3 个环境组织测试用例 [英] Organizing the test cases for 3 environment
问题描述
我是量角器的新手.我已经为开发环境创建了我的测试用例,它工作正常.现在我必须为生产和 QA 移动我的测试用例.
I am new to protractor. I have created my test cases for the development environment and it works fine. Now I have to move my test cases for the production and QA.
由于 3 个环境中的代码相同,我不想为所有 3 个环境创建重复的代码.
Since the code in 3 environment is same I don't want to create duplicate code for all the 3 environment.
简而言之,如果我运行我的代码进行开发,我应该这样做
In short If I run my code for development I should do
protractor conf.js -dev
用于生产
protractor conf.js -production.
-dev 和 -production 是各自的网址.谁能告诉我实现它的方法?还是应该为 3 个环境创建 3 个 conf.js 文件?
-dev and -production are the respective url. Can anyone tell me a way I can achieve it? or should I create 3 conf.js file for the 3 environments?
推荐答案
将其作为命令行选项传入.
Pass it in as a command line option.
量角器 --baseUrl='http://www.productionUrl.com' conf.js
使用命令行参数也会覆盖您在配置文件中的任何设置.因此,如果您的配置文件具有设置 baseUrl='http://www.test.com'
,它将采用您在命令行中传递的 Url 而不是配置文件.
Using command line arguments will also override any setting you have in your config file. So if your config file had the setting baseUrl='http://www.test.com'
, it will take the Url you passed in the command line instead of the config file.
不过这是个人喜好,我自己有几个配置文件(不同的浏览器、环境等).我 95% 的时间都使用相同的配置,但每隔一段时间,让其他配置只是为了快速访问特定的浏览器/环境/任何东西,这很好.另外,我不必打那么多字:)
It's personal preference though, I myself have several config files (different browsers, environments etc). I use the same config 95% of the time, but every once in awhile it's nice to have the others just for quick access to a specific browser/environment/whatever. Plus I don't have to type as much :)
这篇关于为 3 个环境组织测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!