加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift Test传递参数

发布时间:2020-12-14 05:29:14 所属栏目:百科 来源:网络整理
导读:有谁知道如何为 swift测试提供命令行参数? 我试过了 : 快速测试“myDBName” 但我得到了意外的争论错误. 可能的参数列表是: OVERVIEW: Build and run testsUSAGE: swift test [options]OPTIONS: --build-path Specify build/cache directory [default: ./
有谁知道如何为 swift测试提供命令行参数?

我试过了 :
快速测试“myDBName”

但我得到了意外的争论错误.

可能的参数列表是:

OVERVIEW: Build and run tests

USAGE: swift test [options]

OPTIONS:
  --build-path            Specify build/cache directory [default: ./.build]
  --chdir,-C             Change working directory before any other operation
  --color                 Specify color mode (auto|always|never) [default: auto]
  --configuration,-c     Build with configuration (debug|release) [default: debug]
  --enable-prefetching    Enable prefetching in resolver
  --list-tests,-l        Lists test methods in specifier format
  --parallel              Run the tests in parallel.
  --skip-build            Skip building the test target
  --specifier,-s         Run a specific test class or method,Format: <test-module>.<test-case> or <test-module>.<test-case>/<test>
  --verbose,-v           Increase verbosity of informational output
  -Xcc                    Pass flag through to all C compiler invocations
  -Xlinker                Pass flag through to all linker invocations
  -Xswiftc                Pass flag through to all Swift compiler invocations
  --help                  Display available options

有没有其他方法来传递args? (环境变量等?)

实际上,您可以使用环境来完成它.

具有以下内容的测试:

final class HelloTests: XCTestCase {
    func testExample() {
        XCTAssertEqual(String(cString: getenv("SOMETHING")),"else")
    }

    static var allTests = [
        ("testExample",testExample),]
}

使用swift命令行将成功:

SOMETHING=else swift test

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读