Too many tests are run (and some fail) when test methods exist in more than 1 test module #1711
Labels
bug
Identifies work items for known bugs
critical
Marks a bug as a must-fix, showstopper issue
feature-unit-testing
Milestone
Using the Test Explorer commands in Excel 2016 32-bit, I added a test module, and a single test method, to an empty Excel 2016 project. And then, again using the Test explorer menu commands, added another test module and single test method. I then edited the name of the 2nd test module's test method name to TestMethod2 for clarity (although with scoping, I shouldn't need to). So, I have:
TestModule1.TestMethod1
TestModule2.TestMethod2
All other module/test initialization/Cleanup methods have the default name. The Assert objects are each defined using Late-binding.
When I executed the tests, I got VBE errors because the Assert object was not set, so I added debug.print statements to each method.
This is the output in the debug window (with comments added afterwards):
As you can see, Rubberduck had treated
TestMethod2
as if it belonged toTestModule1
and when it tried to execute it, the Module/Test had not been initialized. Later, when it tries to run methods in TestModule2, it erroneously tried to run TestMethod1 (which fails), and then when it tries to run TestMethod2 (as it should, for TestModule2), it fails unexpectedly (although I think it's because the Assert object has been destroyed by me Ending the code (when TestMethod1 failed).Furthermore, Rubberduck tried to call each Test Method exactly twice. And it does so whether the Reparse state results in errors, or results in success.
Unfortunately, I can't repeat this behavior all of the time, but it is reproducible, and in my experience, once you get the errors, you will repeatedly get the errors until you edit the module and trigger a reparse. I suspect that this is a parser error under certain parse results. That is, parse results do not appear to be deterministic / consistent.
Here are the module contents:
The text was updated successfully, but these errors were encountered: