我们正在从 Visual Studio 测试迁移到 xunit。在 VStests 中,我们可以使用 TestContext 访问运行时测试参数。我希望使用 msbuild 在运行时从命令行提供的测试中设置一个全局变量。有人可以帮助找出 xunit 中的 TestContext 等效项吗?
没有TestContext在XUnit中 https://github.com/xunit/xunit/issues/594.
运行测试时我找不到处理环境参数的规范方法,因此我依赖于 JSON 文件。例如。:
{
"Browser": "Chrome",
"BasePath": "localhost:4200",
"BaseApiPath": "http://localhost:50204/"
}
C# code:
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "environment.json");
string json = File.ReadAllText(path);
Configuration = JsonConvert.DeserializeObject<TestingConfiguration>(json);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)