‘No such module XCTest’ while trying to create a unit test class and importing ‘XCTest’

huangapple go评论68阅读模式
英文:

'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.

huangapple
  • 本文由 发表于 2023年2月24日 17:02:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75554520.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定