Sample iOS mobile tests project
This sample demonstrates iOS testing fundamentals in Katalon Studio.
The Application Under Test (AUT) is the Coffee Timer
application. You can learn more about mobile testing in this document: Introduction to mobile testing.
- iOS setup. To set up Xcode simulators/ real iOS devices, you can refer to this document: [Mobile] iOS Setup.
Open the sample iOS test project
To open the iOS sample project, in Katalon Studio, go to File > New Sample Project > Sample iOS Mobile Tests Project.
Alternatively, you can download the iOS sample project from our GitHub repository: iOS sample.
Prepare the iOS application file
The Coffee Timer
application located in the App
folder of this sample project is pre-built and signed by the Katalon team to only run on Katalon devices.
As part of the iOS development procedure, to execute the sample test cases with your iOS devices, you need to build and sign the Coffee Timer
application for your iOS devices. Follow these steps:
For Xcode simulators
To execute the sample test cases with Xcode simulators, you need to prepare an .app
file.
-
Open the
Coffee Timer.xcodeproj
project file with Xcode. To find the project save location, go to <your-project-folder> > App > Your-First-iOS-App > Coffee Timer. Double-click theCoffee Timer.xcodeproj
file.
-
After opening the project in Xcode, choose one of the iOS simulators to launch the apps.
-
To build the
.app
file, click Product > Build.Wait for the build to finish, to find the
app
file, go to~/Library/Developer/Xcode/DerivedData/Coffee Timer/Build/Products/Debug-iphonesimulator/Coffee Timer.app
.Note:- To quickly search for the
DerivedData
folder, copy and paste the following path~/Library/Developer/Xcode/DerivedData
into the Spotlight.
- To quickly search for the
-
Copy and paste the
Coffee Time.app
file into theApp
folder of the sample project. Katalon will use this file to start theCoffee Time
application.
For real iOS devices
To execute mobile testing with real iOS devices, you need to prepare an .ipa
file.
-
Open the
Coffee Timer.xcodeproj
project file with Xcode. To find the project save location, go to <your-project-folder> > App > Your-First-iOS-App > Coffee Timer. Double-click theCoffee Timer.xcodeproj
file.
-
After opening the project in Xcode, select a registered iOS device to launch the apps.
-
In the General tab, set the deployment iOS version and select the device type in the Deployment Info section.
-
Switch to the Signing & Capabilities tab, check the Automatically manage signing box, then choose the team that has your device registered in the Apple Developer Portal.
-
To build the
.ipa
file, click Product > Build. -
To archive the
.ipa
file, click Product > Archive. If the archive builds successfully, it appears in the Archives organizer. To open the Archives organizer, choose Window > Organizer and click Archives.
Select the archive you want to export, then click Distribute App and follow the instructions to get the
.ipa
file. Here, we choose a development provisioning profile to export theCoffee Timer.ipa
file.
-
Verify the
.ipa
file, do as follows:- Navigate to Window > Devices and Simulators in Xcode.
- Choose your device from the Devices list.
-
Click Add (+) to browse the
.ipa
file.
-
Once installed successfully, the application appears in the Installed Apps section.
-
Put the
Coffee Time.ipa
file into theApp
folder of the sample project. Katalon will use this file to start theCoffee Time
application.
iOS sample project components
Custom keywords
You can use custom keywords in the test case. To learn more about custom keywords, you can refer to this document: Introduction to custom keywords.
Katalon creates the sample.Common.startApplication
custom keyword to define the absolute path for starting the iOS application. To see the custom keyword, in the Test Explorer panel, go to Keywords > sample > Common.groovy.
Parameter | Type | Mandatory | Description |
---|---|---|---|
appPath | String | Yes | The absolute path of the application installation file. |
uninstallAfterCloseApp | boolean | Yes | true if uninstalling the application automatically after run. |
flowControl | FailureHandling | Optional | Specify failure handling schema to determine whether the execution should be allowed to continue or stop. To learn more about failure handling settings, you can refer to this document: Failure handling. |
public class Common {
@Keyword
def startAppliucation() {
String appPath = RunConfiguration.getProjectDir() + '/App/Coffee Timer.ipa'
Mobile.startApplication(appPath, false)
}
}
- If you change the name of the
Coffee Timer
application while building it, make sure to change the absolute path to the new file accordingly. For example, if the application name isCoffee Timer2.ipa
, the absolute path should be/App/Coffee Timer2.ipa
. - If you are running test cases with Xcode simulators, the path should lead to the
Coffee Timer.app
file instead.
Test cases
To access test cases in this project, go to the Test Cases folder in the Test Explorer panel.
There are two test cases for different purposes:
-
The test case Mexican Coffee Timer starts and stops the timer for making a Mexican coffee. In this example, we run the test case with a real iOS device.
- Start the
Coffee Timer.ipa
application. Here, we use thesample.Common.startApplication
custom keyword to run the application. - Tap Mexican. We set the timeout for 0 seconds.
- Tap Start. We set the timeout for 0 seconds.
- Tap 3:19. We set the timeout for 0 seconds.
- Tap Stop. We set the timeout for 0 seconds.
- Tap Back. We set the timeout for 0 seconds.
- Close the application.
You can see the test script as follows:
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
CustomKeywords.'sample.Common.startAppliucation'()
Mobile.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Mexican'), 'Mexican')
Mobile.tap(findTestObject('XCUIElementTypeStaticText - Mexican'), 0)
Mobile.tap(findTestObject('XCUIElementTypeButton - Start'), 0)
Mobile.tap(findTestObject('XCUIElementTypeStaticText - 319'), 0)
Mobile.tap(findTestObject('XCUIElementTypeButton - Stop'), 0)
Mobile.tap(findTestObject('XCUIElementTypeButton - Back'), 0)
Mobile.closeApplication() - Start the
-
The test case Verify the main list verifies the list of the coffee name in the application. In this example, we run the test case with a real iOS device.
- Start the
Coffee Timer.ipa
application. Here, we use thesample.Common.startApplication
custom keyword to run the application. - Verify if the application is showing the Mexican item.
- Verify if the application is showing the Colombian item.
- Verify if the application is showing the Coffees item.
- Close the application.
You can see the test script as follows:
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
CustomKeywords.'sample.Common.startAppliucation'()
Mobile.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Mexican'), 'Mexican')
MobileBuiltInKeywords.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Colombian'), 'Colombian')
MobileBuiltInKeywords.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Coffees'), 'Coffees')
Mobile.closeApplication() - Start the
Test suites
To access the test suite in this project, in the Test Explorer panel, go to the Test Suites > Smoke Tests folder. This test suite combines the two test cases shown above.
Execute selected test case or test suite
To execute a test case or a test suite in the sample project:
- Select the test case/test suite you want to execute.
-
On the main toolbar, select iOS as the device type in the dropdown list next to Run.
-
In the displayed iOS Devices dialog, select an iOS device or Xcode simulator, then click OK.
Katalon Studio executes the iOS test with the recorded steps accordingly.
-
Observe the test result in the Log Viewer tab. To learn more about analyzing test execution logs, you can refer to this document: [WebUI] Analyze Test Execution Logs and Debug the Test Case.
Note:- You can view test results in the Result tab at the test suite level. The test results can be Passed, Failed, Error, or Incomplete. To learn more about the test status, you can refer in this document: View and Customize Execution Log.
- After executing test suites, you can view your reports and details in
<your-project-folder>/Reports
. Katalon Studio also supports exporting test reports into different formats, such as HTML, CSV, PDF, and JUnit. - For real-time monitoring and better reporting capabilities, consider integrating your project with Katalon TestOps. Learn more about test result reports here: Upload Test Results to Katalon TestOps from Katalon Studio.