Skip to content

AlwaysUseLowerCamelCase warning on tests #922

Closed
@AdamXA

Description

@AdamXA

Running:
swift format lint --strict --configuration .swift-format --recursive .
returns the following:
MySubjectsClientTests.swift:7:16: warning: [AlwaysUseLowerCamelCase] rename the function 'getData_returnsMySubjectResponse_onSuccess' using lowerCamelCase

Documentation states that:

This rule does not apply to test code, defined as code which:

Contains the line import XCTest
The function is marked with @Test attribute

.swift-format

{
  "version": 1,
  "lineLength": 100,
  "indentation": {
    "spaces": 4
  },
  "maximumBlankLines": 1,
  "respectsExistingLineBreaks": true,
  "lineBreakBeforeControlFlowKeywords": true,
  "lineBreakBeforeEachArgument": true
}

MySubjectsClientTests.swift

import Foundation
import Testing

final class MySubjectsClientTests {
    @Test func getData_returnsMySubjectResponse_onSuccess() async throws {
// code removed
        #expect(true == true)
    }
}

also doesn't seem to recognise when import XCTest is present.

Seems fine with rules like NeverUseForceTry which also do not apply to test code.

Swift version 6.0.1 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
swift format -v main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions