diff --git a/docs/faq.md b/docs/faq.md index bfed90a4f..71c567b75 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -5,6 +5,29 @@ title: FAQ Frequently Asked Questions =========================== +error: `interface not found in source` +-------------------------------------- + +!!! tip "v3.6.0" + + Version [`v3.6.0`](https://github.com/vektra/mockery/releases/tag/v3.6.0) of mockery fixed a bug in how files were detected to be auto-generated. Many users may find that mockery is suddenly unable to find mocks after upgrading to `v3.6.0`. Try providing: + + ```yaml title="" + include-auto-generated: true + ``` + + in your mockery config to see if this resolves the issue. + +This log message indicates that an interface was explicitly listed in the mockery config but it was not found in the source. This can happen for a number of reasons: + +1. The package name was misspelled +2. The interface name was misspelled +3. The `#!yaml include-auto-generated: false` parameter was set (of which `false` is the default) and the interface lived in an auto-generated file. + +Setting `#!yaml log-level: debug` can provide a lot of insight into mockery's decision tree, so we recommend inspecting these logs for further clues into why the interface was not found. + +For more details on `include-auto-generated`, visit [the related documentation](include-auto-generated.md). + error: `no go files found in root search path` --------------------------------------------- diff --git a/docs/generate-directive.md b/docs/generate-directive.md index ef1760110..92d380d77 100644 --- a/docs/generate-directive.md +++ b/docs/generate-directive.md @@ -1,4 +1,4 @@ -## Description +:octicons-tag-24: v3.6.0 An alternative way to configure mocks is to use the `#!go //mockery:generate` directive. Mockery parses the doc comments and allows you to override configuration of specific interfaces in the source code. For example: diff --git a/internal/cmd/mockery.go b/internal/cmd/mockery.go index 4998845d6..ac48645e6 100644 --- a/internal/cmd/mockery.go +++ b/internal/cmd/mockery.go @@ -396,7 +396,8 @@ func (r *RootApp) Run() error { log.Error(). Str(logging.LogKeyInterface, ifaceName). Str(logging.LogKeyPackagePath, packagePath). - Msg("interface not found in source") + Str(logging.LogKeyDocsURL, logging.DocsURL("/faq/#error-interface-not-found-in-source")). + Msg("interface not found in source. View the linked documentation for possible reasons why this might occur.") } } if foundMissing { diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 9457b93eb..49833b145 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -17,6 +17,7 @@ import ( const ( LogKeyBaseDir = "base-dir" LogKeyDir = "dir" + LogKeyDocsURL = "docs-url" LogKeyFile = "file" LogKeyInterface = "interface" LogKeyImport = "import" diff --git a/mockery-tools.env b/mockery-tools.env index 672311eab..207b00cb4 100644 --- a/mockery-tools.env +++ b/mockery-tools.env @@ -1 +1 @@ -VERSION=v3.6.0 +VERSION=v3.6.1