Open tomialagbe opened 1 month ago
Hi. I think the problem is not directly related to v-analyzer, but to how V treats test files as internal and external ones.
Try changing file_manager_test.v
to:
module main
fn test_read_page() {
file_mgr := FileManager{}
file_mgr.read_page()
}
The module main
at the start is important, so that V will consider the test as an internal one (see the note for internal tests in https://github.com/vlang/v/blob/master/doc/docs.md#test-files).
Without it, the test file is considered to be an entirely separate program, and is compiled without having access to any of the symbols from the other files in src/ (i.e. you would have to import everything that you want to test in it, and you can not import the main
module).
You can also try v test .
in the src/ folder. It will pass for a _test.v file, that has module main
at its top, and will fail, for one that lacks it:
Describe the bug
Given a v project with these two files
Expected Behavior
FileManager
should be shownCurrent Behavior
FileManager
structReproduction Steps
v new <project_name>
file_manager.v
andfile_manager_test.v
file_manager.v
pub fn (f FileManager) read_page() {}
// src/file_manager_test.v fn test_read_page() { file_mgr := FileManager{} file_mgr.read_page() }