【问题标题】:'No such module XCTest' while trying to create a unit test class and importing 'XCTest'\'No such module XCTest\' while trying to create a unit test class and importing \'XCTest\'
【发布时间】:2023-02-24 17:44:53
【问题描述】:

我刚开始学习单元测试。创建项目时我没有选中“包括测试”复选框。当我尝试自己创建单元测试用例类时,我在导入 XCTest 的行中收到一条警告,提示“没有这样的模块 XCTest”。

我在我创建的文件夹下创建了一个类为 Unit Test Case 类的文件。在里面我得到了警告。

【问题讨论】:

    标签: ios swift xcode unit-testing compiler-warnings


    【解决方案1】:

    它缺少应用程序的目标。要添加目标, You can find add target in the Editor of Menu bar

    选择之后, Unit testing bundle

    这将创建一个包含符合 XCTestCase 类的类的文件。 单击超链接文本,您将能够找到所需的屏幕截图。

    (或者)

    添加

    @testable import (App Name)
    

    之后

    import XCTest
    

    线来消除这个警告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2020-11-05
      • 1970-01-01
      • 2021-12-23
      • 2022-11-20
      • 2020-04-10
      • 2020-02-09
      相关资源
      最近更新 更多