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

Godot Debugger Pauses on Exception During GUT Test, Preventing Test Completion #676

Open
niklasb22 opened this issue Dec 15, 2024 · 1 comment

Comments

@niklasb22
Copy link

Versions

  • Godot: 4.3
  • GUT: 9.3
  • OS: Win11

The Bug

I am encountering an issue where the Godot debugger pauses when an exception occurs during a GUT test, preventing the test from completing. I would like the test to fail instead of the debugger pausing.

Steps to Reproduce:

  1. Set up a GUT test in your Godot project.
  2. Trigger an error in the test, such as calling a nonexistent function.
  3. Run the test.
@bitwes
Copy link
Owner

bitwes commented Dec 16, 2024

Unfortunately there is no way to detect when an exception occurs. Godot doesn't have any exception handling and they have stated that it won't ever be added. Issue #210 has more information.

If you have a test that will always cause an error you can skip it if the debugger is enabled by checking EngineDebugger.is_active(). If you do this you should call fail_test or pending when the debugger is active so that you can see a test was skipped.

func test_causes_error():
    if(EngineDebugger.is_active()):
        pending("Skipped test because debugger is on")
        return

    # put your test logic here

If you want to skip an entire script if the debugger is enabled you can implement the should_skip_script method. This will mark the script as "risky" and none of the tests will be run.

func should_skip_script():
	return EngineDebugger.is_active()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants