Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
---------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/generate-directive.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
const (
LogKeyBaseDir = "base-dir"
LogKeyDir = "dir"
LogKeyDocsURL = "docs-url"
LogKeyFile = "file"
LogKeyInterface = "interface"
LogKeyImport = "import"
Expand Down
2 changes: 1 addition & 1 deletion mockery-tools.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=v3.6.0
VERSION=v3.6.1