首页 > 解决方案 > 如何从 Catch2 测试用例中访问自定义命令行选项?

问题描述

我使用自定义主文件添加了我自己的命令行选项:

https://github.com/catchorg/Catch2/blob/master/docs/own-main.md#adding-your-own-command-line-options

  // ...
  auto cli 
    = session.cli() // Get Catch's composite command line parser
    | Opt( height, "height" ) // bind variable to a new option, with a hint string
        ["-g"]["--height"]    // the option names it will respond to
        ("how high?");        // description string for the help output

  // ...
}

现在我想height在测试用例中使用命令行选项。最好的方法是什么?

标签: c++command-linecatch2

解决方案


推荐阅读