swa*_*ddy 6 c# xunit xunit.net
我们正在从Visual Studio测试迁移到xunit。在VStests中,我们可以使用TestContext访问运行时测试参数。我正在使用msbuild从命令行在运行时提供的测试中设置全局变量。有人可以帮助找出xunit中的TestContext等效项吗?
运行测试时我找不到处理环境参数的规范方法,因此我依赖于 JSON 文件。例如:
{
"Browser": "Chrome",
"BasePath": "localhost:4200",
"BaseApiPath": "http://localhost:50204/"
}
Run Code Online (Sandbox Code Playgroud)
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "environment.json");
string json = File.ReadAllText(path);
Configuration = JsonConvert.DeserializeObject<TestingConfiguration>(json);
Run Code Online (Sandbox Code Playgroud)