【问题标题】:How to process Boost.Test output with Eclipse如何使用 Eclipse 处理 Boost.Test 输出
【发布时间】:2010-03-22 10:27:23
【问题描述】:

我正在使用 Eclipse CDT 和 Boost.Test(带有 Boost.Build)。 我希望 Eclipse 解析在构建期间运行测试套件期间生成的 Boost.Test 的输出。
有谁知道如何实现这一目标? 提前致谢

【问题讨论】:

  • @Martin:好建议,已实施。

标签: c++ unit-testing eclipse-cdt boost-test


【解决方案1】:

转到窗口 > 首选项。在首选项对话框中,从选项树中选择 C/C++ > Build。在错误解析器下,单击“添加...” 在新对话框中,将“Regex Error Parser”替换为“Boost Unit Test Error Parser”之类的内容。

在“错误解析器选项”窗格中,添加以下行。我不能保证这些规则能捕捉到 boost 单元测试的所有可能输出,但到目前为止它们对我有用,我们以后总是可以添加更多:

Severity | Pattern                                          | File | Line | Description
Error    | (.*)\((\d*)\): ((fatal )?error in ".*":.*)       | $1   | $2   | $3
Error    | \*\*\* (\d* failures detected in test suite ".*")|      |      | $1
Info     | (.*)\((\d*)\): (last checkpoint)                 | $1   | $2   | $3

请注意,新的解析器不会自动在现有项目中使用。要为现有项目启用解析器,请转到项目 > 属性、C/C++ 生成项目、错误解析器选项卡。如果新添加的解析器不在列表中,请单击“恢复默认值”,它现在应该可用了。

【讨论】:

  • 非常非常酷。感谢您的出色回答。在 Eclipse 3.6.2 上为我工作。为现有项目启用新解析器的项目设置的位置略有变化。现在是 Project > Properties > C/C++ Build > Settings > Error Parsers 选项卡(或者只是在“类型过滤器文本”框中输入“设置”。)
【解决方案2】:

还有一个不错的插件叫 cdt c/c++ tests runner,它支持 Google 测试、boost 测试和 qt 测试。

您可以在以下链接中找到说明:

https://github.com/xgsa/cdt-tests-runner/wiki/Tutorial

我已经用了一段时间了,觉得它高效又好用。它具有 Java 的 JUnit 插件等功能。

【讨论】:

    【解决方案3】:

    我的 IDE (gedit) 遇到了同样的问题,无法识别 Boost.Test 的输出格式(由于某种原因,它与 gnu 和 clang 输出不兼容)。

    您可以通过将其粘贴到您的测试中以编程方式更改输出格式:

    #include<boost/test/output/compiler_log_formatter.hpp>
    struct gedit_config{
        struct formatter : boost::unit_test::output::compiler_log_formatter{
            void print_prefix(std::ostream& out, boost::unit_test::const_string file, std::size_t line){
                out<< file <<':'<< line <<": ";
            }
        };
        gedit_config(){boost::unit_test::unit_test_log.set_formatter(new formatter);}
    };
    BOOST_GLOBAL_FIXTURE(gedit_config);
    

    (这里的原始答案:https://stackoverflow.com/a/64619245/225186

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-22
      • 2012-10-25
      • 2022-06-30
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2022-07-10
      • 1970-01-01
      相关资源
      最近更新 更多