【发布时间】:2020-12-19 11:10:26
【问题描述】:
我正在尝试重新创建我的 BeforeTestRun 步骤,以便在整个执行而不是每个线程中只运行一次我的设置。
我查看了自定义部署步骤,我已经实现了一些,但是对于我的设置,我需要从 app.config 文件中引入一些值,我正在尝试类似这样的操作
我的 Default.srprofile 文件包含:
<DeploymentTransformation>
<GlobalSteps>
<Custom type="Test.CustomDeploymentStep, Test"></Custom>
</GlobalSteps>
</DeploymentTransformation>
还有我的 CustomDeploymentStep.cs:
public class CustomDeploymentStep : IDeploymentTransformationStep
{
public static string baseUrl;
public void Apply(IDeploymentContext deploymentContext)
{
baseUrl = ConfigurationManager.AppSettings["URL"];
}
public void Restore(IDeploymentContext deploymentContext)
{
DoSomething();
}
}
我的应用配置包含以下内容:
<add key="URL" value="http://google.com" />
但这不起作用,ConfigurationManager.AppSettings 只返回一个键和一个值
"key" : "TestProjectRetargetTo35Allowed" "value":"true"
如何将我的配置从 app.config 加载到 CustomDeploymentStep 的 Apply() 方法中?
另外,如果有更好/更有效的方式来生成具有线程安全执行的规范流中的预定义数据,请告诉我
【问题讨论】:
-
不是
ConfigurationManager.AppSettings-- 复数吗? -
确实是错字
-
愚蠢的问题,但是您使用的是 .NET Framework 还是 .NET Core?
-
@GregBurghardt NET 框架
-
您可以在您的问题中添加更多 app.config 吗?
标签: c# .net specflow configurationmanager