我们正在从 visual studio 测试迁移到 xunit。在 VStests 中,我们可以使用 TestContext 访问运行时测试参数。我希望在运行时使用 msbuild 从命令行提供的测试中设置全局变量。有人可以帮助找出 xunit 中的 TestContext 等效项吗?
最佳答案
There is no TestContext
in XUnit .
在运行测试时,我找不到处理环境参数的规范方法,所以我依赖于 JSON 文件。例如:
{
"Browser": "Chrome",
"BasePath": "localhost:4200",
"BaseApiPath": "http://localhost:50204/"
}
C#代码:
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "environment.json");
string json = File.ReadAllText(path);
Configuration = JsonConvert.DeserializeObject<TestingConfiguration>(json);
关于c# - Xunit 中类似于 Visual studio 测试中的 TestContext 的属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40121043/