Getting Started with iOS development: writing Ocunit test methods-applying test methods

Source: Internet
Author: User
Tags requires

Applying test methods

Application testing is a test of the application's functionality, which is specific to the click of a button to trigger an event, so it is mainly the test presentation layer. Let's look at the methods in the view controller viewcontroller.m that need testing and then design the test cases.

@implementation Viewcontroller 
     
-(void) viewdidload 
     
{ 
     
[super Viewdidload]; 
     
} 
     
-(void) didreceivememorywarning 
     
{ 
     
[super didreceivememorywarning]; 
     
} 
     
-(Ibaction) OnClick: (ID) Sender { 
     
//close keyboard 
     
[self.txtrevenue Resignfirstresponder]; 
     
Self.lblTax.text =[self Calculate:self.txtRevenue.text]; 
     
} 
     
Calculate personal income Tax 
     
-(nsstring*) Calculate: (nsstring*) revenue { 
     
... 
     
} 
     
@end

Whether Viewdidload and didreceivememorywarning need to be tested depends on whether we have some code written in this method, and we don't need to test them for now. OnClick: Is the response user clicks the Calculation button method, it needs to test. Calculate: The method is the business logic method, and we tested it in the logic test, do we need to test it again? In general, it should only be in the logical test, however, if the method requires an external environment (depending on other classes or requires a special running environment, etc.), the logical test is not available and the test is applied, and the application test is able to run on the device, which provides a real, real test environment.

Here we implement the OnClick: method of application testing, we want to simulate Click Button Event processing, its input conditions through the text box control input, the output result is displayed through the label control. Design test Cases Select common values and boundary values as input values, and the text box's keyboard is limited to the numeric keypad.

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.