【发布时间】:2018-06-20 15:50:36
【问题描述】:
我有一组用 VS 2017,Nunit 开发的硒测试(项目类型 - 使用 .net 框架 452 的类库。在我的 OneTimeSetUp 中,我正在阅读 app.config,它定义了一些东西,例如 Web URL、数据库连接字符串、Web登录用户名/密码等
示例:
<appSettings>
<add key="Browser" value="IExplorer" />
<add key="User" value="xxx" />
<add key="Password" value="xxx" />
<add key="BaseURL" value="http://ccc.com" />
<add key="DefaultImplicitDriverWait" value="15" />
<add key="TestRailIntegrationValue" value="False" />
<add key="GenerateCustomReport" value="False" />
</appSettings>
<connectionStrings>
<add name="DB1" connectionString="Data Source=db_name;Initial Catalog=db_instance;User Id=userid;Password=pwd;" />
</connectionStrings>
然后运行测试,我使用 nunit 命令行 -- 示例
cd "C:\path-to-repo location"
packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console pathToDll --where "cat == Demo"
cmd /k
现在,只要我针对一个环境,它就可以正常工作。现在,当我需要将测试切换到不同的环境时,在从命令行或 VS 2017 运行测试之前,我需要更改指向不同环境变量的 app.config bu。
那么有没有办法,我可以在命令行中将这些值作为参数传递,然后在执行任何测试之前更新app.config?
如果有任何替代解决方案/建议,我很高兴得到所有建议。
【问题讨论】:
标签: c# visual-studio selenium command-line nunit