DEV Community

Cover image for Adding Testing integration in swift using xctest
Japneet Singh
Japneet Singh

Posted on

Adding Testing integration in swift using xctest

Introduction

Welcome to an introduction to how to integrate testing in ios projects. The framework I chose for my project is XCtest which is an automation tool provided by Apple. Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing. documentation

Setup

Please follow the instruction to set up the XCTest for your Xcode project.

  1. Image description
  2. Image description
  3. Image description

To run the tests in swift

$ swift test
Enter fullscreen mode Exit fullscreen mode

Shortcuts

These shortcuts are essential when writing unit tests in Xcode.

  1. Command + U to run all tests.
  2. Command + Option + Control + G to run latest test.

Errors encountered

Image description

Fixed errors

Image description

    if(input.isEmpty){
        print("Error. Please enter input folder or add suffix to file name")
        return
      }
Enter fullscreen mode Exit fullscreen mode

Outcome

Learning from testing is to cover all arguments or other ways possibilities of having errors. While testing helps to come up with all scenarios that can cover all errors. Commits: commits
Image description

Top comments (0)