Robolectric 不知道 \p{LATIN} 字符 属性 名字

Robolectric does not know \p{LATIN} char property name

我有一个正则表达式

final public static Pattern ONLY_LATIN_LETTERS = Pattern.compile("[\p{LATIN}\p{S}\p{P} ]*");

在 Android 设备上运行良好。 当我 运行 使用 Robolectric 进行测试时,我在创建模式时遇到异常,因为 LATIN 未被识别为字符 属性 名称。如果我使用:

final public static Pattern ONLY_LATIN_LETTERS = Pattern.compile("[\p{IsLatin}\p{S}\p{P} ]*");

它适用于 Robolectric 但它会在设备上引发异常。

这是否意味着 Robolectric 无法可靠地测试设备上的行为?

我正在使用:

testCompile "org.robolectric:robolectric:3.0"
testCompile "org.robolectric:shadows-support-v4:3.0"
testCompile "org.robolectric:shadows-multidex:3.0"
compile 'junit:junit:4.8.2'

目前我的解决方案是 运行 与 AndroidJunit4 运行ner 的 Android 连接测试。 在这种情况下,您 运行 真实设备上的应用程序,您会看到可用的字符 属性 名称。