Supplement to Swift Unit testing

Source: Internet
Author: User

Recently, younger brother in his own study of Swift, accustomed to writing while writing unit tests while writing logic, in the Xcode environment without unit testing, writing is not a real feeling.

As to how to create unit test, how to write, not the subject of this article, because read a lot of Baidu to the swift unit test, has been very graphic introduction to tell you how to write unit test. But the big question is, whether you call the class in your project anyway in the test class and say it's undefined, how does this happen? Fqgoogle a hand. Finally understand.

First of all, your project and test project is separate 2 target, if you need to call in the unit test project in the project of the class, you must go to the unit test the class and the class dependence class, choose this diagram:

Then you can refer to it in the test method.

Another option is to use the keyword public, the public of the class being tested, and the method to be tested public, so that the import of your project name in the test project can be called, but this method has some drawbacks, that is, public will limit the return type is not allowed, Just to be blunt, these types can not be translated, and there is no need for each clsss and func public, personal advice or plan I.

No technical content of the article, purely remark.

Finally the sentence: Baidu harm, less use once is, Google you will come back?

Supplement to Swift Unit testing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.