@@ -172,6 +172,72 @@ final class AlwaysUseLowerCamelCaseTests: LintOrFormatRuleTestCase {
172
172
. nameMustBeLowerCamelCase( " test_HappyPath_Through_GoodCode_Throws " , description: " function " ) )
173
173
}
174
174
175
+ func testIgnoresUnderscoresInConditionalTestNames( ) {
176
+ let input =
177
+ """
178
+ import XCTest
179
+
180
+ let Test = 1
181
+ class UnitTests: XCTestCase {
182
+ #if SOME_FEATURE_FLAG
183
+ static let My_Constant_Value = 0
184
+ func test_HappyPath_Through_GoodCode() {}
185
+ private func FooFunc() {}
186
+ private func helperFunc_For_HappyPath_Setup() {}
187
+ private func testLikeMethod_With_Underscores(_ arg1: ParamType) {}
188
+ private func testLikeMethod_With_Underscores2() -> ReturnType {}
189
+ func test_HappyPath_Through_GoodCode_ReturnsVoid() -> Void {}
190
+ func test_HappyPath_Through_GoodCode_ReturnsShortVoid() -> () {}
191
+ func test_HappyPath_Through_GoodCode_Throws() throws {}
192
+ #else
193
+ func testBadMethod_HasNonVoidReturn() -> ReturnType {}
194
+ func testGoodMethod_HasVoidReturn() {}
195
+ #if SOME_OTHER_FEATURE_FLAG
196
+ func testBadMethod_HasNonVoidReturn2() -> ReturnType {}
197
+ func testGoodMethod_HasVoidReturn2() {}
198
+ #endif
199
+ #endif
200
+ }
201
+ #endif
202
+ """
203
+ performLint ( AlwaysUseLowerCamelCase . self, input: input)
204
+ XCTAssertDiagnosed (
205
+ . nameMustBeLowerCamelCase( " Test " , description: " constant " ) , line: 3 , column: 5 )
206
+ XCTAssertDiagnosed (
207
+ . nameMustBeLowerCamelCase( " My_Constant_Value " , description: " constant " ) , line: 6 , column: 16 )
208
+ XCTAssertNotDiagnosed (
209
+ . nameMustBeLowerCamelCase( " test_HappyPath_Through_GoodCode " , description: " function " ) )
210
+ XCTAssertDiagnosed (
211
+ . nameMustBeLowerCamelCase( " FooFunc " , description: " function " ) , line: 8 , column: 18 )
212
+ XCTAssertDiagnosed (
213
+ . nameMustBeLowerCamelCase( " helperFunc_For_HappyPath_Setup " , description: " function " ) ,
214
+ line: 9 , column: 18 )
215
+ XCTAssertDiagnosed (
216
+ . nameMustBeLowerCamelCase( " testLikeMethod_With_Underscores " , description: " function " ) ,
217
+ line: 10 , column: 18 )
218
+ XCTAssertDiagnosed (
219
+ . nameMustBeLowerCamelCase( " testLikeMethod_With_Underscores2 " , description: " function " ) ,
220
+ line: 11 , column: 18 )
221
+ XCTAssertNotDiagnosed (
222
+ . nameMustBeLowerCamelCase(
223
+ " test_HappyPath_Through_GoodCode_ReturnsVoid " , description: " function " ) )
224
+ XCTAssertNotDiagnosed (
225
+ . nameMustBeLowerCamelCase(
226
+ " test_HappyPath_Through_GoodCode_ReturnsShortVoid " , description: " function " ) )
227
+ XCTAssertNotDiagnosed (
228
+ . nameMustBeLowerCamelCase( " test_HappyPath_Through_GoodCode_Throws " , description: " function " ) )
229
+ XCTAssertDiagnosed (
230
+ . nameMustBeLowerCamelCase( " testBadMethod_HasNonVoidReturn " , description: " function " ) ,
231
+ line: 16 , column: 10 )
232
+ XCTAssertNotDiagnosed (
233
+ . nameMustBeLowerCamelCase( " testGoodMethod_HasVoidReturn " , description: " function " ) )
234
+ XCTAssertDiagnosed (
235
+ . nameMustBeLowerCamelCase( " testBadMethod_HasNonVoidReturn2 " , description: " function " ) ,
236
+ line: 19 , column: 12 )
237
+ XCTAssertNotDiagnosed (
238
+ . nameMustBeLowerCamelCase( " testGoodMethod_HasVoidReturn2 " , description: " function " ) )
239
+ }
240
+
175
241
func testIgnoresFunctionOverrides( ) {
176
242
let input =
177
243
"""
0 commit comments