如何在Xcode 7中的UITest期间获取文本字段的值?

时间:2016-09-29 13:23:13

标签: macos xcode7 xcode-ui-testing

我试图在Mac上测试一个简单的Celsius Fahrenheit转换器。我正在运行macOS Sierra和Xcode 7.2.1。

enter image description here

当我运行以下测试时

env REPO=https://myrepo.com/site-content sh -c 'svn ls -R $REPO | \
    grep "/\$" | while read dir; do svn co --depth=empty $REPO/$dir $dir; done'

我基本上在Celsius字段中输入值21并且期望在华氏度字段中获得值69.8。但我收到错误消息

测试失败: - [CFConverterUITests testExample2]失败:((str)等于(@" 69.8"))失败:("< 4536392e 38000000>&#34 ;)不等于("< 30c15800 01000000>")

有谁知道什么是错的,怎么办?

1 个答案:

答案 0 :(得分:2)

XCTAssertEqual不会处理对象。你的断言应该是XCTAssert([str isEqualToString:@"69.8"]);