gpt4 book ai didi

Swift 测试传递参数

转载 作者:IT王子 更新时间:2023-10-29 05:50:07 25 4
gpt4 key购买 nike

有谁知道如何为快速测试提供命令行参数?

我试过:快速测试“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

还有其他方法可以传递参数吗? (环境变量等?)

最佳答案

您确实可以利用环境来做到这一点。

具有以下内容的测试:

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

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

会成功,使用swift命令行:

SOMETHING=else swift test

关于Swift 测试传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51893096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com