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
Test Explorer gets stuck in infinite mode on error in ModuleInitialize #2520
Comments
Are you able to confirm the version of Rubberduck that you're using? Also, it sounds like VBA is executing while you're refreshing. Do you have any events triggering VBA code? Are you able to post the module/procedure that is executing when you hit the Debug button? |
Sorry, it's on the current version 2.0.11.2453. The code generating the error is called by the test explorer inside the ModuleInitialize procedure, I have no event code, and the error is in Access SQL where I had a syntax error, but it's irrelevant which function generates the error. The behavior is the same if I just write a mock-up with a Err.raise in it.
The log says
|
Oh, I didn't realize you were running tests, I thought the error was being raised as you were adding tests. It seems you're missing a You also have You'll also need to make sure you've added a Reference to Rubberduck, using Tools..References, in order for the early-binding of Rubberduck won't work unless the VBA can be compiled. Try refactoring so the code begins like this: Option Explicit
Option Private Module
'@TestModule
Private Assert As New Rubberduck.AssertClass
Public Sub RaisesError()
Err.Raise 42, "Source", "Error"
End Sub
'@ModuleInitialize
Public Sub ModuleInitialize()
'this method runs once per module.
RaisesError
End Sub
'.... |
The code compiles and runs fine apart from the error when executing the ModuleInitialize. The first sub is in another module, I just copied it in for reference. Also, the missing apostrophe is due to bad copy&pasting skills on my part (haven't used Markdown in a while) ;) I assure you that the error is not on my part. |
Ah, so your tests aren't running because the You'll need a way to prevent the error from throwing in that procedure. Once the error is suppressed, I suspect that Rubberduck won't know whether the procedure was successful, and will just proceed to attempt to execute the tests We might need a way to abort tests if the ModuleInitialize method fails. |
That's correct, However, the actual issue (for me, at least) is not that the tests aren't running but that the Test Explorer fails to recover and becomes unresponsive. I could of course create an error handler inside ModuleInitialize, but it would be more developer-friendly if the Test Explorer remained usable if you inadvertently create an error. The general "go to faulty line" feature of VBA is quite useful, so it'd be a shame to just swallow all errors. At the current point in time, if you introduce an error in the ModuleInitialize routine, you have to restart the host application to make Rubberduck usable again. It's not a deal-breaker but can become annoying and having completely fault-free methods here is a rather high bar for devs. Basically, if any of the "around the test" subs fail, the Test Explorer could stop trying to execute the current test module and go to the next one. |
hmm, maybe we need an abort tests button that is enabled while tests are running. |
@ThunderFrame one problem is that RD's UI thread is waiting for the Aborting executing VBA code that was triggered by RD isn't possible without redesigning and rewriting the whole |
To fix this issue, all we need to do is catch any |
Should be fixed as of 68a3d50 |
Using MS Access Professional 2016 x64, I had an error in a table set up statement in ModuleInitialize inside one of my test modules. The VBA editor error window popped up, I clicked on Debug (the same happens if you click on End). After that, the Test Explorer became unresponsive (displayed the "loading" animation indefinitely) until I restarted the host app.
The text was updated successfully, but these errors were encountered: