Styling and coloring your XCTest logs on Xcode Console

Related tags

Logging XLTestLog
Overview

XLTestLog

Notes with Xcode 8 and XLTestLog

Since Xcode 8 killed XcodeColors, the current way using XCTestLog on Xcode 8 is just plain texts with emoji. You could still use XCTestLog to stylish XCTest logs without coloring.

XLTestLog v1.1+ will remove "color code" from logs if you don't privide a UseXcodeColors == YES preprocess macro.

Introduction

XLTestLog is a lightweight library for stylish XCTest logs. It makes your testing logs more readable in Xcode Console.

  • Reformat the log messages to make them more readable.
  • Use indentations and Emoji bullets for different logs.
  • Paint log messages and highlight important keywords using XcodeColors.
  • Only test logs will be styled. You can distinguish colored test logs from other logs (e.g. NSLog()).

The following is an example for test results in Xcode Console using XLTestLog:

And this is without using XLTestLog:

The readability between them is quite different. The original test code for the console logs is simple (one passed test, one failed test, one measure task, and one message fromNSLog()):

@implementation XLTestLogDevTests

- (void)testPassedCase {
  XCTAssert(YES, @"Pass");
  NSLog(@"This is a message from `NSLog()`.");
}

- (void)testFailureCase {
  XCTAssert(NO, @"Fail");
}

- (void)testPerformanceExample {
  // This is an example of a performance test case.
  [self measureBlock:^{
    int j = 0;
    for (int i = 0; i < 1000000; i++) {
      j += i;
    }
  }];
}
@end

How to use

No additional code is needed to use XLTestLog.

  1. Include XLTestLog in your test target (see Installation section).
  2. Install XcodeColors plugin.
  3. Just run your test, and see the delightful logs in the Xcode Console.

Release Notes

You should also install XcodeColors

Currently, you should use XLTestLog with XcodeColors. If you don't, it would show the color code in the logs.

In the next release, XLTestLog will read the environment variable XcodeColors to decide whether using XcodeColors to paint log messages or not.

Installation

Before installing XLTestLog, please read the section Release Notes.

via CocoaPods

You can install XLTestLog simply via CocoaPods:

target :MyAppTests do
  pod 'XLTestLog'
end

Manually

You can install XLTestLog manually via adding files in XLTestLog/ directory into your project.

About

Contribution

Any help would be most welcome. Even buy me a beer. :p

Author

License

XLTestLog is available under the MIT license. See the LICENSE file for more info.

You might also like...
Gedatsu provide readable format about AutoLayout error console log
Gedatsu provide readable format about AutoLayout error console log

Gedatsu Gedatsu provide readable format about AutoLayout error console log Abstract At runtime Gedatsu hooks console log and formats it to human reada

A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as
A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as "the console")

CleanroomASL Notice: CleanroomASL is no longer supported The Apple System Log facility has been deprecated by Apple. As a result, we've deprecated Cle

Simple Design for Swift bridge with Javascript. Also can get javascript console.log.
Simple Design for Swift bridge with Javascript. Also can get javascript console.log.

SDBridgeOC is here. If your h5 partner confused about how to deal with iOS and Android. This Demo maybe help. YouTube video is here. bilibili Video is

Swift Logging Utility for Xcode & Google Docs
Swift Logging Utility for Xcode & Google Docs

QorumLogs Swift Logging Utility in Xcode & Google Docs

Logger for Xcode
Logger for Xcode

CSwiftLog Usage Log.log("Message text without category") Log.my.log("Message text with custom category") Log.network.log("Message text with network ca

Shows your current framerate (fps) in the status bar of your iOS app
Shows your current framerate (fps) in the status bar of your iOS app

WatchdogInspector Shows your current framerate (fps) in the status bar of your iOS app Be a good citizen! Don't block your main thread! WatchdogInspec

Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs.
Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs.

Example mail composer Example Report Diagnostics is a library written in Swift which makes it really easy to share Diagnostics Reports to your support

A simple logger for your swift applications.

AHQSLogger A simple logging system. Usage import AHQSLogger Use the following methods for loggging. Logging an information / debug You can log a simp

TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.

Please star this github repository to stay up to date. TraceLog Introduction TraceLog is a highly configurable, flexible, portable, and simple to use

Comments
  • Instead of

    Instead of "Test Case-1 launched", just print the full / readable name of the test!

    Hi thanks for writing XLTestLog. It's made working with XCTest much more fun.

    I think the test cases can be even clearer by removing numbering. Test numbers aren't useful anyway. Just use the full name of the test.

    Would be good if it is made readable: e.g. testThisWorks => "This works" passed.

    I think there's can be some lessons of simplicity and conciseness that can be learned from mocha, the Javascript test runner!

    opened by fatuhoku 2
  • Some Improvements

    Some Improvements

    Here are some improvements to XLTestLog

    • Set indentation settings to two spaces at the project level
    • Set XLTestLogDev deployment target to iOS 6
    • Remove the XAspect dependency
    • Write to XCTestLog's logFileHandle property instead of stdout
    • Silence some warnings
    opened by 0xced 1
Owner
Xaree Lee
Xaree Lee
BadgeLog - A light lib that helps and centralize logs in your application

BadgeLog BadgeLog is an iOS Swift library that helps you manage logs within your

Daniele 1 Feb 2, 2022
This is how you can manage and share logs in iOS application.

Logging in Swift In this example, you can find how to print all the logs effciently in iOS application. Along with, you will find how to share logs fo

Nitin Aggarwal 8 Mar 1, 2022
Simply, Logify provides instant colorful logs to improve log tracking and bug tracing

Logify Simply, Logify provides instant colorful logs to improve log tracking and bug tracing. Why I need to use Logify? As discussed before in a lot o

Furkan KAPLAN 13 Dec 28, 2022
Customizable Console UI overlay with debug log on top of your iOS App

AEConsole Customizable Console UI overlay with debug log on top of your iOS App AEConsole is built on top of AELog, so you should probably see that fi

Marko Tadić 142 Dec 21, 2022
XCLog is a Swift extension that helps you print something in console when debugging your projects.

XCLog XCLog is a Swift extension that helps you print something in console when debugging your projects. Installation Open Xcode > File > Add Packages

null 1 Jan 9, 2022
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.

TinyConsole TinyConsole is a tiny log console to display information while using your iOS app and written in Swift. Usage Wrap your Main ViewControlle

Devran Cosmo Uenal 2k Jan 3, 2023
JustLog brings logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support for logz.io available.

JustLog JustLog takes logging on iOS to the next level. It supports console, file and remote Logstash logging via TCP socket with no effort. Support f

Just Eat 509 Dec 10, 2022
Delightful console output for Swift developers.

Rainbow adds text color, background color and style for console and command line output in Swift. It is born for cross-platform software logging in te

Wei Wang 1.7k Dec 31, 2022
Gedatsu provide readable format about AutoLayout error console log

Gedatsu Gedatsu provide readable format about AutoLayout error console log Abstract At runtime Gedatsu hooks console log and formats it to human reada

bannzai 520 Jan 6, 2023