Unit tests in iOS development (i) Contrast ocunit and Ghunit

Source: Internet
Author: User

This article does not discuss what unit testing is, or the pros and cons of it in a project, and I think unit testing is an effective tool for developers to ensure the quality of output code. This article from the user's point of view to compare the current more popular two unit test framework, to provide you with some suggestions. If you are not quite sure about the role of unit testing in engineering, or the development model of TDD, refer to: Test-driven Development and testing.

This article compares the unit Test framework common to two iOS developments: Ocunit, which is officially integrated into the Xcode 4.x version; Ghunit, the most recommended test framework with GUI interface. The first glimpse of the two test framework is very similar, and hands-on use will find the difference. The details of the difference makes the two frame in different angles of the pros and cons.

Ocunit

Ocunit is the Xcode 4.x integrated Unit test framework, the test in Ocunit is divided into two categories, one is called Logic Tests, the other is called Application Tests. Logic tests prefers the so-called white-box test to test more detailed logic in engineering; application tests prefers black-box testing, or interface testing, for testing interfaces that interact directly with the user.

Adding unit Tests

Ocunit is Xcode integrated, so its integration with the project should be the best, add to the cost of the project should also be the lowest. There is a "Include unit Tests" option in the process of creating a new project using Xcode (Figure 1), and a new project automatically generates a logic Tests.

Adding Ocunit Logic tests to an existing project is also not complicated, just add a target of type: "Cocoa Touch Unit Testing Bundle" (Figure 2).

Figure 2, adding a ocunit test to an existing project

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.