Ios Can';t在旧项目上运行UI测试

Ios Can';t在旧项目上运行UI测试,ios,xcode,xcode7,ui-testing,xcode-ui-testing,Ios,Xcode,Xcode7,Ui Testing,Xcode Ui Testing,我正在尝试在一个旧项目上添加并运行带有Xcode 7的UI自动化测试。 以下是我所做的: 添加了一个新的UI测试目标 将该目标的编译器版本更改为默认编译器(Apple LLVM 7.0) 使用iPhone6plusIOS9模拟器录制了一个测试(工作起来很有魅力) 现在,当我尝试运行录制的测试时,我得到以下错误: 失败:捕获到“NSInternalInconsistencyException”,“无目标” 通过测试配置指定的应用程序路径: testBundleURL:file:///xxxxxxx

我正在尝试在一个旧项目上添加并运行带有Xcode 7的UI自动化测试。 以下是我所做的:

  • 添加了一个新的UI测试目标
  • 将该目标的编译器版本更改为默认编译器(Apple LLVM 7.0)
  • 使用iPhone6plusIOS9模拟器录制了一个测试(工作起来很有魅力)
  • 现在,当我尝试运行录制的测试时,我得到以下错误:

    失败:捕获到“NSInternalInconsistencyException”,“无目标” 通过测试配置指定的应用程序路径: testBundleURL:file:///xxxxxxxxxxx/PlugIns/PageonceUITests.xctest/ productModuleName:(空) testsToSkip:(空) testsToRun:(空) ReportResultsToId:否 会话标识符:7045B650-CDAF-4EC9-9738-83F78E1514D8 pathToXcodeReportingSocket:(空) 失效性能指标:无治疗失效基线失效:无 baselineFileURL:(空) targetApplicationPath:(空) targetApplicationBundleID:(空)


    此错误似乎是因为在添加UI测试目标时选择了“要测试的目标”字段。UI测试目标->常规选项卡下的“目标应用程序”属性是否正确显示了所选的主应用程序? 一个快乐的配置应该是这样的

    2015-10-04 17:30:50.960 XCTRunner[22941:4703128] Found configuration <XCTestConfiguration: 0x7fbf3050c8b0>
    
    testBundleURL:file:///Users/username/Library/Developer/Xcode/DerivedData/App-fxeyzrynjcscxzaxjvmnormcjhbr/Build/Products/Debug-iphonesimulator/APPUITests-Runner.app/PlugIns/APPUITests.xctest/
                  productModuleName:APPUITests
                        testsToSkip:(null)
                         testsToRun:(null)
                 reportResultsToIDE:YES
                  sessionIdentifier:<__NSConcreteUUID 0x7fbf30503430> B324DF9D-769F-4217-901F-24482A719005
         pathToXcodeReportingSocket:(null)
          disablePerformanceMetrics:no
    treatMissingBaselinesAsFailures:no
                    baselineFileURL:(null)
              targetApplicationPath:/Users/username/Library/Developer/Xcode/DerivedData/APP-fxeyzrynjcscxzaxjvmnormcjhbr/Build/Products/Debug-iphonesimulator/AppName.app
          targetApplicationBundleID:com.bundle.appBundle.app.dev
                   reportActivities:no
    
    2015-10-04 17:30:50.960 XCTRunner[22941:4703128]找到了配置
    testBundleURL:file:///Users/username/Library/Developer/Xcode/DerivedData/App-fxeyzrynjcscxzaxjvmnormcjhbr/Build/Products/Debug-iphonesimulator/APPUITests-Runner.app/PlugIns/APPUITests.xctest/
    productModuleName:应用程序测试
    testsToSkip:(空)
    testsToRun:(空)
    ReportResultsToId:是
    会话标识符:B324DF9D-769F-4217-901F-24482A719005
    pathToXcodeReportingSocket:(空)
    失效性能指标:否
    处理丢失基线失败:否
    baselineFileURL:(空)
    targetApplicationPath:/Users/username/Library/Developer/Xcode/DerivedData/APP fxeyzrynjcscxzaxjvmnormcjhbr/Build/Products/Debug iphonesimulator/AppName.APP
    targetApplicationBundleID:com.bundle.appBundle.app.dev
    报告活动:没有
    
    我遇到了同样的问题,并通过不使用此答案中所述的旧版生成位置解决了它:

    如果我使用“Legacy”,可以记录UI测试,但当我尝试运行它们时失败。使用“Unique”作为设置,它们工作正常。(这可以在新项目中复制)


    Xcode→ 偏好→ 位置→ 派生数据→ 先进的。。。→ [x] 独特的

    我在物理iPad上也遇到了同样的问题。
    当我最终删除了应用程序及其所有数据,然后关闭并重新启动设备时,问题得到了解决。

    这可能是由于您的目标设置出现了问题

    尝试以下方法

  • 删除现有目标
  • 再次选择“iOS UI测试包”,创建新目标
  • 然后逐个链接测试文件

  • 它可以工作。

    您必须在相关的“生成设置”部分的UITest target中添加一个自定义的“用户定义设置””属性:

    用钥匙:

    TEST\u TARGET\u NAME
    YourTargetName

    使用\u XCTRUNNER
    (可选)


    现在您可以运行UI测试了。

    我遇到了同样的问题,并解决了它。