英文:
'No such module XCTest' while trying to create a unit test class and importing 'XCTest'
问题
我刚刚开始学习单元测试。在创建项目时,我没有勾选“包括测试”复选框。当我尝试自己创建一个单元测试用例类时,我在导入 XCTest 的那一行收到了一个警告,上面写着“没有 XCTest 模块”。我在一个自己创建的文件夹下创建了一个单元测试用例类文件,在其中我遇到了这个警告。
英文:
I'm just starting with learning Unit testing. I didn't check the 'Include tests' check box while creating the project. When I tried to create a Unit Test Case class by myself, I received a warning in the line where XCTest is imported saying 'No such module XCTest'.
I created a file with class Unit Test Case class under a folder that I made. Inside which i got the warning.
答案1
得分: 1
It's missing target to the application. To add target,
You can find add target in the Editor of Menu bar
After that select,
Unit testing bundle
This will create a file with a class that conforms to XCTestCase class.
You will be able to find the required screenshots on clicking the hyperlink texts.
(or)
Add
@testable import (App Name)
after the
import XCTest
line to silence this warning.
英文:
It's missing target to the application. To add target,
You can find add target in the Editor of Menu bar
After that select,
Unit testing bundle
This will create a file with a class that conforms to XCTestCase class.
You will be able to find the required screenshots on clicking the hyperlink texts.
(or)
Add
@testable import (App Name)
after the
import XCTest
line to silence this warning.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论