DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • Extending Java APIs: Add Missing Features Without the Hassle
  • The SPACE Framework for Developer Productivity

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • Extending Java APIs: Add Missing Features Without the Hassle
  • The SPACE Framework for Developer Productivity
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Integrate FitNesse with XCTest Using Xcode8

Integrate FitNesse with XCTest Using Xcode8

The latest release of the OCSlim project has integrated FitNesse test reports along with XCTest framework. In this post, we will see how to integrate Fitness with XCTest.

Shashikant Jagtap user avatar by
Shashikant Jagtap
·
Sep. 27, 16 · Tutorial
Like (1)
Save
Tweet
Share
3.48K Views

Join the DZone community and get the full member experience.

Join For Free

fitnesse for ios

recently fitnesse has entered into the world of ios development. an ocslimproject has enabled an atdd and bdd practices in ios development world. this project enabled us writing and blazing fast acceptance test with fitnesse for ios. thanks to paul stringer and other contributors.  you can read more about what are the problems that fitnesse can solve in article ‘ acceptance testing for ios ‘ by paul stringer.

as of now fitnesse acceptance for ios running in the separate process and reports are generated by a different mechanism which doesn't feel like fitnesse and is actually part of the development and ci workflow. the good news is the latest release of the ocslim project has integrated fitnesse test reports along with xctest framework which means we can execute fitnesse tests along with unit tests using xcode-build. in this post, we will see how to integrate fitness with xctest.

fitnesse and xctest

pre-requisite

in order to get fitnesse and xctest working we need to have the following toolkit:

  • rubygems setup and cocoapods [gem install cocoapods]
  • xcode 8 (should work on 7.3 as well)
  • java 1.8 – scared ? yes, java! required to launch fitnesse. don’t worry we are not touching it [brew install java]
  • nodejs [brew install node]
  • ios-sim [npm install -g ios-sim]

once we've got these we are good to go.

create a new xcode project

let’s create a new xcode project in swift with unit tests only, without ui tests and core data.

let’s build this project and run unit tests for the blank project by pressing cmd+b and cmd + u. now we have a blank app running in the simulator.

get fitnesse target templates for xcode

there are some pre-defined targets as part of the “ocslimproject”  we need to download and add to xcode. just run these commands from terminal/iterm

$ git clone https://github.com/paulstringer/ocslimprojectxcodetemplates.git  
$ cd ocslimprojectxcodetemplates   
$ make

now we have all the necessary targets templates copied over to xcode. now launch xcode and select new targets for ios. you will see acceptance and acceptance unit tests bundle got added to xcode.

targets

add acceptance and acceptance unit test target to project

now that we have all the predefined targets for fitnesse. just add “acceptance tests” target from the template and “acceptanceunittests” target from the bundle. you will need “fitnesse suite page name” to create this target but just put “ocslimprojectexamplepage” there for now . add your ‘acceptancetests’ target as a ‘target dependancy’ of this new target in build phases. this ensures that it the latest code has been built prior to the tests being run.

targets

if you click build at this stage, it will fail because we don’t have pod dependencies added yet.

add pod dependencies

we need to create a “podfile” at the root of the project with the following content.

target 'acceptancetests' do     
   pod 'ocslimproject' 
end   

target 'acceptanceunittests' do     
   pod 'ocslimprojecttestbundlesupport' 
end

now, we can run ‘pod install’ at this stage and close the current xcode session and open project workspace.

pod_install

build acceptance tests target

at this stage, we should be able to build the “acceptance tests” target. if you are using xcode8, you might see some warning related to the swift3 syntax. just click on ‘edit-> convert-> to current swift syntax

error

just click on ‘edit-> convert-> to current swift syntax and this error will go away.

now you should be able to build an “acceptance tests” target. once, build is successful, you should see “launchfitnesse” script is generated in the root of the project. we can launch and execute the fitness test as shown below.

build_acceptace

test acceptanceunittests target

now if you select “acceptanceunittarget” and press cmd+u.

runxcuitest

now we can see that fitnesse tests are running as shown above.  we can add this to main scheme to make sure we are running it after the unit tests to follow proper development workflow. we can build and run it as our normal unit tests.

taking control with bundler, fastlane, and trainer

now that , we have seen how to run fitnesse acceptance tests from xcode but it’s a good idea to run it with fastlane.  we can also take control of version of cocoapods and fastlane by using bundler . let’s create a gemfile at the root of the project with the following gem.

source "https://rubygems.org"   
gem 'cocoapods' 
gem 'fastlane'   plugins_path = file.join(file.dirname(__file__), '.', 'pluginfile') eval(file.read(plugins_path), binding) if file.exist?(plugins_path)

let’s also create directory “fastlane” and make “fastfile” with following content

fastlane_version "1.104.0"  

default_platform :ios   
platform :ios do   
before_all do     
   system "rm -rf ../test_reports/"     
   system "bundle install"     
   system "pod install"     
    system "bundle exec fastlane add_plugin trainer"   
end     
desc "runs all the unit tests and fitnesse aceptance tests"   
lane :xctest_fitnesse do    
  scan(scheme: "fitnessexctestdemo", 
   destination: 'platform=ios simulator,name=iphone 7 plus,os=10.0',  
   output_directory: "test_reports/",    
    output_types: "html",    
    fail_build: false    )
   trainer(output_directory: "test_reports/trainer_report/")   
end 
end

now we will create a “fastlane/pluginfile” to add “trainer” plugin.

gem 'fastlane-plugin-trainer'


after running “bundle install” we should be able to run those test from command line like this :

xcfitnesse

source code

the source code for this demo is available on github “ fitnesse-xctest “. just run following commands ?

$ git clone https://github.com/shashikant86/fitnesse-xctest
$ cdfitnesse-xctest$ bundle install
$ bundle execfastlane xctest_fitnesse

youtube video



conclusion

in this way, we can execute fitnesse ios acceptance test as part of our development workflow along with our unit tests. this allows us to get early feedback and seamless integration with ide like xcode8.

FitNesse unit test Integration XCode Build (game engine)

Published at DZone with permission of Shashikant Jagtap, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Scaling Site Reliability Engineering (SRE) Teams the Right Way
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • Extending Java APIs: Add Missing Features Without the Hassle
  • The SPACE Framework for Developer Productivity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: