Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
The test just checks that the methods don't cause a crash when printing a message to different outputs.
  • Loading branch information
ns-vasilev committed Jan 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2cc139d commit d048f7c
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Tests/LogTests/IntegrationTests/LogIntegrationTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// log
// Copyright © 2024 Space Code. All rights reserved.
//

import Log
import XCTest

// MARK: - LogIntegrationTests

final class LogIntegrationTests: XCTestCase {
// MARK: Properties

private var sut: Logger!

// MARK: XCTestCase

override func setUp() {
super.setUp()
let formatters: [ILogFormatter] = [
TimestampLogFormatter(dateFormat: "dd/MM/yyyy"),
PrefixLogFormatter(name: "LogIntegrationTests"),
]

sut = Logger(
printers: [
ConsolePrinter(
formatters: formatters
),
OSPrinter(
subsystem: .subsystem,
category: .category,
formatters: formatters
),
],
logLevel: .all
)
}

override func tearDown() {
sut = nil
super.tearDown()
}

// MARK: Tests

// The test just checks that the methods don't cause a crash
// when printing a message to different outputs.
func test_logDoesNotThrowUnexpectedBehavior_whenLogMessages() {
// 1. Print an info message
sut.info(message: .message)

// 2. Print a debug message
sut.debug(message: .message)

// 3. Print an error message
sut.error(message: .message)

// 4. Print a fault message
sut.fault(message: .message)
}
}

// MARK: - Constants

private extension String {
static let subsystem = "subsystem"
static let category = "category"
static let message = "text"
}

0 comments on commit d048f7c

Please sign in to comment.