TAEF 支持测试程序集配置文件。 配置文件的名称应与测试程序集 + “.config”相同。 如果有名为 MyUnitTests.dll的测试程序集,则应 MyUnitTests.dll.config命名配置文件。
配置文件应放置在与测试程序集文件相同的目录中。
.NET 配置文件
.NET 配置文件采用以下格式的 XML 文件:
<configuration>
<appSettings>
<add key="AssemblySetup" value="Assembly setup configuration information"/>
<add key="ClassSetup" value="Class setup configuration information"/>
<add key="TestSetup" value="Test setup configuration information"/>
<add key="Test" value="Test configuration information"/>
</appSettings>
</configuration>
请注意,配置文件是名称/值对的集合。
从测试中读取配置文件
可以使用 System.Configuration.ConfigurationManager 类从配置文件中读取数据。 例如,
NameValueCollection appStgs = ConfigurationManager.AppSettings;
Log.Comment(appStgs["AssemblySetup"]);