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"]);