1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9 #import "DynamicTestCase.h" 10 11 /** 12 * ResourceTestCase is a subclass of DynamicTestCase that generates tests based 13 * on resources. Subclasses should override the bundle, directories, predicates, 14 * and dynamicTestsForResources methods. 15 */ 16 @interface ResourceTestCase : DynamicTestCase 17 18 /** 19 * Returns an array of NSBundle objects to search for resources. 20 * By default, returns the main bundle and the bundle for the class. 21 */ 22 + (NSArray<NSBundle *> *)bundles; 23 24 /** 25 * Returns an array of directory paths (relative to the bundles' resource paths) 26 * to search. Subclasses should override to specify directories containing 27 * resources. 28 */ 29 + (NSArray<NSString *> *)directories; 30 31 /** 32 * Returns a dictionary mapping resource keys to predicates. 33 * Each predicate is a block that takes a filename and returns a BOOL indicating 34 * a match. Subclasses should override to specify predicates for matching 35 * resources. 36 */ 37 + (NSDictionary<NSString *, BOOL (^)(NSString *)> *)predicates; 38 39 /** 40 * Returns a dictionary mapping test names to test blocks, given a dictionary of 41 * resources. Subclasses should override to provide tests for combinations of 42 * resources. 43 * 44 * @param resources A dictionary mapping resource keys to resource file paths. 45 * @return A dictionary mapping test names to test blocks. 46 */ 47 + (NSDictionary<NSString *, void (^)(XCTestCase *)> *)dynamicTestsForResources: 48 (NSDictionary<NSString *, NSString *> *)resources; 49 50 @end 51