Visual studio code 无法在visual studio代码中为测试使用调试标志

Visual studio code 无法在visual studio代码中为测试使用调试标志,visual-studio-code,.net-core,xunit,Visual Studio Code,.net Core,Xunit,我在VisualStudio代码中有一个单元测试设置,需要读取测试数据文件,将其加载到HtmlDocument HtmlAgilityPack并测试解析器类。我在班上名列前茅 public class MegaParserTests{ private HtmlDocument _hd; private MegaParser _parserUT; public ParserTests() { _parserUI = new MegaParser(); _hd = new Htm

我在VisualStudio代码中有一个单元测试设置,需要读取测试数据文件,将其加载到HtmlDocument HtmlAgilityPack并测试解析器类。我在班上名列前茅

public class MegaParserTests{

private HtmlDocument _hd;
private MegaParser _parserUT;

public ParserTests() {
    _parserUI = new MegaParser();
    _hd = new HtmlDocument()

#if DEBUG
    filePath = "data/theDoc.html";
#else
    filePath = @"../../../data/theDoc.html";
#endif

    var docStr = File.ReadAllText(filePath);
    _hd.LoadHtml(doc);
}
}
我使用了if-DEBUG,因为文件路径似乎会根据我是调试测试还是从命令行执行dotnet测试而改变。但是,当我进行dotnet测试时,如果达到调试条件,并且我得到了错误的文件路径,则返回顶部。为什么运行dotnet测试时运行时认为我处于调试模式。。我怎样才能改变这一点呢?

实际上,dotnet测试默认使用发布版本配置。。。尝试使用-configuration标志强制发布生成配置:

dotnet test -c Release
-c |-配置

要在其下生成的配置。默认值为Release