Skip to content

VojtaStavik/XCTest-Log-Formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple XCTest Log Formatter in Swift

This is the repo with the sample code for the blog post "Simple XCTest Log Formatter in Swift".

For more information visit https://vojtastavik.com/2019/04/23/xctest-log-formatter/.

Example

All tests passed

Custom XCTest Log Formatter example

Some of the tests failed

Custom XCTest Log Formatter fail example

Usage

  1. Clone this repository
$ git clone https://github.com/VojtaStavik/XCTest-Log-Formatter.git
  1. Make sure the formatter file is executable:
$ cd XCTest-Log-Formatter
$ chmod +x format_xctest_log.swift
  1. Copy the formatter file to the repo you want to use it in or simply copy it to /usr/local/bin to make it accessible from everywhere:
cp format_xctest_log.swift /usr/local/bin
  1. Because the formatter formats only the test logs, you need to separate the build and test steps.

Here are the example commands for Alamofire:

# The build step still uses xcpretty :
$ xcodebuild build-for-testing \
-workspace Alamofire.xcworkspace \
-scheme "Alamofire iOS" \
-sdk iphonesimulator \
ENABLE_TESTABILITY=YES \
| xcpretty

# The test step uses the new formatter:
$ xcodebuild test-without-building \
-workspace Alamofire.xcworkspace \
-scheme "Alamofire iOS" \
-destination "id=FE78C58A-0776-41C0-BE1C-FC7C3A07853A" \
| format_xctest_log.swift

About

The sample code from the "Simple XCTest Log Formatter" article.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages