From ceecf1fae8129662381559686fd9adfe7b12a1cf Mon Sep 17 00:00:00 2001 From: Trond Einar Snekvik Date: Thu, 7 Jun 2018 10:06:39 +0200 Subject: [PATCH] Add support for :mock_suffix Adds support for :mock_suffix when generating mock setup and teardown functions. Also documents both prefix and suffix in the helper script guide. --- auto/generate_test_runner.rb | 3 ++- docs/UnityHelperScriptsGuide.md | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 427c513..84daa42 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -26,6 +26,7 @@ class UnityTestRunnerGenerator framework: :unity, test_prefix: 'test|spec|should', mock_prefix: 'Mock', + mock_suffix: '', setup_name: 'setUp', teardown_name: 'tearDown', main_name: 'main', # set to :auto to automatically generate each time @@ -148,7 +149,7 @@ class UnityTestRunnerGenerator mock_headers = [] includes.each do |include_path| include_file = File.basename(include_path) - mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}/i + mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}$/i end mock_headers end diff --git a/docs/UnityHelperScriptsGuide.md b/docs/UnityHelperScriptsGuide.md index 4242990..8b0df1b 100644 --- a/docs/UnityHelperScriptsGuide.md +++ b/docs/UnityHelperScriptsGuide.md @@ -159,6 +159,12 @@ CMock (see CMock documentation). This generates extra variables required for everything to run smoothly. If you provide the same YAML to the generator as used in CMock's configuration, you've already configured the generator properly. +##### `:mock_prefix` and `:mock_suffix` + +Unity automatically generates calls to Init, Verify and Destroy for every file +included in the main test file that starts with the given mock prefix and ends +with the given mock suffix, file extension not included. By default, Unity +assumes a `Mock` prefix and no suffix. ##### `:plugins` -- GitLab