From 0cfb521f7f22c27b8a277dcb875843f93e32337d Mon Sep 17 00:00:00 2001 From: Aleh Dzenisiuk Date: Thu, 30 Nov 2023 18:07:03 +0100 Subject: [PATCH] Add a helper generating parameter dictionaries from enums --- MMMTestCase.podspec | 2 +- Sources/MMMTestCase/MMMTestCase.swift | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/MMMTestCase.podspec b/MMMTestCase.podspec index ee55d9d..53197d8 100644 --- a/MMMTestCase.podspec +++ b/MMMTestCase.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.name = "MMMTestCase" - s.version = "1.8.0" + s.version = "1.9.0" s.summary = "Our helpers for FBTestCase and XCTestCase" s.description = s.summary s.homepage = "https://github.com/mediamonks/#{s.name}" diff --git a/Sources/MMMTestCase/MMMTestCase.swift b/Sources/MMMTestCase/MMMTestCase.swift index 73ca5a5..b875e43 100644 --- a/Sources/MMMTestCase/MMMTestCase.swift +++ b/Sources/MMMTestCase/MMMTestCase.swift @@ -4,6 +4,7 @@ // import Foundation +import MMMCommonCore import UIKit #if SWIFT_PACKAGE @@ -87,4 +88,13 @@ extension MMMTestCase { ) } + + /// Helps generating parameter dictionaries suitable for `varyParameters` from enums supporting `CaseIterable`. + public func allTestCases(_ type: T.Type) -> [String: T] { + .init(uniqueKeysWithValues: + T.allCases + .map { (String(MMMTypeName($0).split(separator: ".").last!), $0) } + .sorted { a, b in a.0 < b.0 } + ) + } }