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.