Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 测试不同app.config文件的Windows窗体_C#_.net_Winforms_Testing_Configuration Files - Fatal编程技术网

C# 测试不同app.config文件的Windows窗体

C# 测试不同app.config文件的Windows窗体,c#,.net,winforms,testing,configuration-files,C#,.net,Winforms,Testing,Configuration Files,我们的Windows窗体应用程序由app.config文件配置,有100多台计算机正在运行,并且有多种配置。 我想用不同的app.config文件测试应用程序,我通过调用Windows窗体项目的静态主函数来实现,然后根据配置文件调用多个窗体中的一个窗体 我想使用给定的config.file启动测试: [TestMethod] public void ConfigEurope() { string[] args = new string[1]; args[0] = "C:\app

我们的Windows窗体应用程序由app.config文件配置,有100多台计算机正在运行,并且有多种配置。 我想用不同的app.config文件测试应用程序,我通过调用Windows窗体项目的静态主函数来实现,然后根据配置文件调用多个窗体中的一个窗体

我想使用给定的config.file启动测试:

[TestMethod]
public void ConfigEurope()
{
    string[] args = new string[1];
    args[0] =  "C:\app.Europe.config";
    Program.Main(args);
}

[TestMethod]
public void ConfigAsia()
{
    string[] args = new string[1];
    args[0] =  "C:\app.Asia.config";
    Program.Main(args);
}
如何以编程方式设置配置文件?如何测试正确的表单是否运行?我无法更改应用程序的体系结构


非常感谢

正确的选择是为不同的变体提供配置文件。例:

app.debug.config
app.europe.config
app.usa.config
app.china.config
通过这种方式,我们可以拥有一个基本app.config文件,然后为每个不同的场景拥有单独的配置文件

作为下一步,您必须在项目中为以下各项创建配置

debug
europe
usa
china 
等等

最后一步是选择一个配置,然后运行测试,或者如果您是从命令行运行的,则可以使用
/p:configuration=
参数选择正确的配置来运行测试套件

要设置多个案例的配置,请参阅下面的博客文章