Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-607: GdUnit4 Godot plugin does not find test suites at the root folder #607

Closed
esainane opened this issue Dec 3, 2024 · 1 comment · Fixed by #604
Closed

GD-607: GdUnit4 Godot plugin does not find test suites at the root folder #607

esainane opened this issue Dec 3, 2024 · 1 comment · Fixed by #604
Assignees
Labels
bug Something isn't working
Milestone

Comments

@esainane
Copy link
Contributor

esainane commented Dec 3, 2024

The used GdUnit4 version

4.4.4 (Pre Release/Master branch)

The used Godot version

v4.3.1.rc.mono.custom_build [ff9bc0422]

Operating System

6.11.5+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian GNU/Linux trixie/sid 6.11.5-1~bpo12+1 (2024-11-11) x86_64

Describe the bug

The gdUnit4 settings description for Test Lookup Folder states:

Subfolder where test suites are located (or empty to use source folder directly)

However, leaving this setting empty (or set to /, or res://) will cause gdUnit4 to not find any test suites in the root folder. scan_test_directories starts by examining subfolders, though it is very permissive with any of these test directory settings.

This structure would be bad practice in a proper project, since it has to perform a lot of scanning which a dedicated test directory would avoid. However, this should eliminate much confusion when trying to create a minimal reproducible test project, and wondering why the test suite is silently not being detected.

This is not a problem when using the GdUnit4 Test Adapter via VSTest; tests located in the root folder will be correctly located and executed when going through VSCode. This is only an issue when going through the GdUnit4 Godot Editor plugin.

Steps to Reproduce

  • Configure Test lookup folder in gdUnit4 settings to be blank (or /, or res://)
  • Create a test case in the root directory of the project:
namespace GDUnit4RootTestExample;

using Godot;
using GdUnit4;

using static GdUnit4.Assertions;

[TestSuite]
public class ExampleTest
{
    [TestCase]
    public void FindMe() => AssertBool(true).IsTrue();
}
  • Run tests via VSCode. Observe VSCode finding the test.
  • Run tests via Godot Editor. Observe Godot Editor failing to find the same test.

Minimal reproduction project

gdunit4-root-test-example.zip

@esainane esainane added the bug Something isn't working label Dec 3, 2024
@esainane esainane changed the title GD-606: GdUnit4 Godot plugin does not find test suites at the root folder GD-607: GdUnit4 Godot plugin does not find test suites at the root folder Dec 3, 2024
@MikeSchulze MikeSchulze added this to the 4.4.4 milestone Dec 3, 2024
@MikeSchulze
Copy link
Owner

Thanks for reporting this bug.

MikeSchulze added a commit that referenced this issue Dec 10, 2024
# Why
The GdUnit4 Godot Editor plugin currently does not find any tests in the
project root directory, even when configured to do so.

Fixes #607.

# What
- Refactors external calls to `scan_test_directories` into a new
`scan_all_test_directories` instead. These external calls all had the
form `scan_test_directorys("res://", GdUnitSettings.test_root_folder(),
[])`. This provides a cleaner API, and a logical place to add handling
for the "include all resources" special case.
- When `scan_all_test_directories` is called to determine which resource
paths should be included, and the project is configured to include all
resources, it early returns `["res://"]`. Otherwise, it performs the
current subfolder scanning logic via `scan_test_directories("res://",
GdUnitSettings.test_root_folder(), [])`.
- Fixes a typo: `suits` -> `suites`
- Fixes a typo: `scan_test_directorys` -> `scan_test_directories`

---------

Co-authored-by: Nullpointer <mikeschulze.lpz@gmail.com>
@github-project-automation github-project-automation bot moved this to Done in GdUnit4 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants