Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

A step-by-step tutorial for continuous integration with Jenkins for a Red Hat Mobile Native iOS application-Part 1

November 11, 2016
Juana Nakfour
Related topics:
Developer tools
Related products:
Red Hat build of Node.js

    This post was originally published on redhat.com.

    Part 1: Adding Unit Tests to Native iOS Red Hat Mobile Application Platform Application

    A robust and agile mobile application development environment requires continuous integration and delivery. It also requires an integrated and automated unit testing process that helps bring applications to market successfully. This two-part series details my work done at the Red Hat Open Innovation Labs and as a Mobile Technical Account Manager to capture these mobile innovations in a useful, repeatable way. In part one of this two-part series, I break down the steps to create and unit test a native iOS application using Red Hat Mobile Application Platform. In part two, I’ll show how Jenkins can be used to automate continuous integration and unit testing of that Mobile app. If you would like to try out our Red Hat Mobile Application Platform product please visit our Red Hat Mobile Application Platform site.

    Requirements

    1. Xcode 7.3
    2. Red Hat Mobile Application Platform 3.12 (or later)
    3. Mac OSX El Capitan

    Using the Red Hat Mobile Application Platform portal, create a new project and select the Native iOS hello world project. In this tutorial we will be working with the objective-C application. Copy and git clone the native objective-C project to your development machine. Run the command pod install in the project folder to install all the dependencies. Now we have our project ready to open by Xcode.

    Using Xcode open the file helloworld-ios-app.xcworkspace. Click on the testing navigator tab as shown below. It should all be empty.

    For reference, check out this great documentation.

    Before we start adding unit tests, let’s add two utility functions to add and multiply two numbers. Go back to the code section, right click on helloworld-ios-app folder and add a new file of Cocoa Touch Class. This should create a header file and source file in the folder you chose. Add the two utility functions as seen below:

    screen-shot-2016-11-08-at-3-11-12-pm

    Now that we have the two functions, we can go ahead and start creating unit tests.

    Xcode has 2 types of testing

    1. Functional tests
    2. User Interface tests

    Click back to the test navigator, and let’s add functional tests. Click on the bottom right + menu and choose new unit test target.

     

    NumberOperationUtility.h
    
     <Foundation/Foundation.h>
    @interface NumberOperationUtility : NSObject
       -(int) addTwoNumbers: (int) firstNumber toSecondNumber: (int)secondNumber ;
      -(int) multiplyTwoNumbers: (int) firstNumber toSecondNumber: (int) secondNumber; @end
    
    NumberOperationUtility.m
    
    #import "NumberOperationUtility.h"
    @implementation NumberOperationUtility
     -(int) addTwoNumbers: (int) firstNumber toSecondNumber: (int) secondNumber {
       return firstNumber + secondNumber;
    }
    -(int) multiplyTwoNumbers: (int) firstNumber toSecondNumber: (int) secondNumber {
      return firstNumber*secondNumber;
    } @end

    Give it a name and make sure it is Objective-C for language and then finish. Now we should have a test target along with a unit test template already provided as seen below:screen-shot-2016-11-08-at-3-11-24-pm

    We can either add a new unit test or just change the name of the provided unit test to NumericOperationUnitTest. The code below includes the two unit test for addition and multiplication.screen-shot-2016-11-08-at-3-14-09-pm

    NumericOperationUnitTest.m
    
    #import "NumberOperationUtility.h"
    @interface NumericOperationUnitTest : XCTestCase
    @property (nonatomic) NumberOperationUtility *numberOperation;
    @end
    
    @implementation NumericOperationUnitTest - (void) setUp {
      [super setUp];
      // Put setup code here. This method is called before the invocation of each test method in the class.
      self.numberOperation = [[NumberOperationUtility alloc] init];
    }
    
    - (void) tearDown {
      // Put teardown code here. This method is called after the invocation of each test method in the class.
      [super tearDown];
    }
    
    - (void) testAddition {
      // This is an example of a functional test case.
     // Use XCTAssert and related functions to verify your tests produce the correct results.
      int additionResult=[self.numberOperation addTwoNumbers:100 toSecondNumber:200];
      XCTAssertTrue(additionResult==300,"Addition Test Failed");
    }
    
    - (void) testMultiplication {
     // This is an example of a functional test case.
     // Use XCTAssert and related functions to verify your tests produce the correct results.
     int multiplicationResult=[self.numberOperation multiplyTwoNumbers:100 toSecondNumber:200];
      XCTAssertTrue(multiplicationResult==20000,"Addition Test Failed");
    }
    
    - (void) testPerformanceExample {
     // This is an example of a performance test case.
     [self measureBlock:^{
       // Put the code you want to measure the time of here.
     }];
    }
    
    @end

    To run the test, simply click on the arrow by the test name and the tests should run successfully as seen below:

    screen-shot-2016-11-08-at-3-15-45-pm

    Now, let’s add some UI unit testing. Xcode has an exciting feature where you can actually record your UI tests and it generates the code for the test. First, we will need to make some changes to our template app by adding an alert window that pops up with the cloud response. Change the cloudCall function in HomeViewController.m to the following code:

    - (IBAction) cloudCall:(id)sender {
      [name endEditing:YES];
      NSDictionary *args = [NSDictionary dictionaryWithObject:name.text forKey:@"hello"];
      FHCloudRequest *req = (FHCloudRequest *) [FH buildCloudRequest:@"/hello" WithMethod:@"POST" AndHeaders:nil AndArgs:args];
    
      [req execAsyncWithSuccess:^(FHResponse * res) {
         // Response
         NSLog(@"Response: %@", res.rawResponseAsString);
         result.text = [res.parsedResponse objectForKey:@"msg"];
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Response"
                message:[res.parsedResponse objectForKey:@"msg"]
                delegate:nil
                cancelButtonTitle:@"OK"
                otherButtonTitles:nil];
                [alert show];
      } AndFailure:^(FHResponse * res) {
         // Errors
         NSLog(@"Failed to call. Response = %@", res.rawResponseAsString);
         result.text = res.rawResponseAsString;
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Response"        
                message:res.rawResponseAsString
                delegate:nil
                cancelButtonTitle:@"OK"
                otherButtonTitles:nil]; [alert show]; }];
    }

    You can run the application and try it. Every time the button is tapped, an alert shows up with the response. Now that we have some UI action to test, let’s switch to the test navigation bar and add a new UI unit test. Click on the bottom left + menu item and select new UI Test Target.

    screen-shot-2016-11-08-at-3-16-26-pm

    Give it a name and click finish. Now we should have a new UI test target with some templates to write the tests. Let’s record our test by clicking on the testExample and making sure the cursor is in the testExample function where the code needs to be. Click on the red round circle found at the bottom of the window to start recording.

    screen-shot-2016-11-08-at-3-16-48-pm

    This should actually build the code and launch the emulator. As it is recording, click on the button and wait for the response before clicking on the “OK” of the alert window. You should see something similar to the code below. We added a sleep(10) before tapping on the button to allow FH.init to complete.

    - (void) testExample {
       // Use recording to get started writing UI tests.
       // Use XCTAssert and related functions to verify your tests produce the correct results.
    
       XCUIApplication *app = [[XCUIApplication alloc] init];
       sleep(10);
       [app.buttons[@"Call"] tap];
    
       XCUIElement *okButton = app.alerts[@"Response"].collectionViews.buttons[@"OK"];
       [okButton tap];
    }

    To try out this test, simply run the test and the results should be a success.

    screen-shot-2016-11-08-at-3-17-59-pm

    This concludes part one of our tutorial for adding unit tests to an Red Hat Mobile Application Platform native iOS application. In part two, I’ll show how Jenkins can be used to automate continuous integration and unit testing of that mobile app which will be published next.

    screen-shot-2016-11-08-at-3-18-28-pmJuana Nakfour is a Senior Mobile Technical Account Manager with over 15 years advanced R&D experience in the telecommunications industry. Juana’s focus is broad and include wireless communication networks, embedded/mobile devices and microservices.

    A Red Hat Technical Account Manager (TAM) is a specialized product expert who works collaboratively with IT organizations to strategically plan for successful deployments and help realize optimal performance and growth. The TAM is part of Red Hat’s world class Customer Experience and Engagement organization and provides proactive advice and guidance to help you identify and address potential problems before they occur. Should a problem arise, your TAM will own the issue and engage the best resources to resolve it as quickly as possible with minimal disruption to your business.

    Last updated: October 31, 2023

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI