我正在尝试在ios上实现CI。我在真实设备(iPad)上使用xcodebuild从命令行运行xcode单元测试:
xcodebuild test -project MyProject.xcodeproj -scheme tests DEVELOPMENT_TEAM={DEV_TEAM_ID} -destination platform=iOS,id={DEVICE_UUID} build-for-testing -allowProvisioningUpdates -configuration {Debug/Release}
我有一个单元测试,里面包含NSLog调用。问题是那些日志没有显示在调用xcodebuild的终端窗口中:
Test Suite 'Selected tests' started at 2018-06-07 05:10:45.653
Test Suite 'XcodeTests.xctest' started at 2018-06-07 05:10:45.655
Test Suite 'XcodeTests.xctest' failed at 2018-06-07 05:10:45.655.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.00) seconds
Test Suite 'Selected tests' failed at 2018-06-07 05:10:45.656.
Executed 1 test, with 1 failure (0 unexpected in 0.00 (0.003) seconds
我已经从Xcode的Window->Devices and Simulators-> View Device Logs
查看了设备日志,看起来他们在那里但是作为通知(也许是他们注意事项的事实):
Jun 7 05:10:45 MyiPad tests(XcodeTests)[21982] <Notice>: ENTERED TEST
Jun 7 05:10:45 MyiPad tests[21982] <Notice>: CREATED EXPECTATIONS
我已经在另一台Mac上测试了这种启动方法与另一台连接的iPad,它奇怪地起作用。它工作的机器在终端中显示NSLog消息的配置如下:
System Software Overview:
System Version: macOS 10.13.2 (17C88)
Kernel Version: Darwin 17.3.0
Boot Volume: SYSTEM
Boot Mode: Normal
Computer Name: Mac001
User Name: MacUser001
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 7 days 48 minutes
XCODE VERSION DETAILS:
Xcode 9.2
Build version 9C40b
Device iOS Version: 11.2 (15C114)
它没有在终端中显示NSLog的其他配置如下:
System Software Overview:
System Version: macOS 10.13.3 (17D47)
Kernel Version: Darwin 17.4.0
Boot Volume: SYSTEM
Boot Mode: Normal
Computer Name: Mac002
User Name: MacUser002
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 7 days 48 minutes
XCODE VERSION DETAILS:
Xcode 9.2
Build version 9C40b
Device iOS Version: 10.2 (14C92)
可能是什么问题?它可能来自设备或mac工作站吗? (我没有物理访问任何一个,只是远程到mac)。
答案 0 :(得分:0)
实际上是针对iOS 10+版本的,看起来NSLog被视为
答案 1 :(得分:0)
就像丹说的那样,如果您想查看测试中正在打印在控制台上的消息,则最好使用printf
而不是NSLog
示例printf("%s", [yourNSString UTF8String]);