Have you ever wanted to properly unit test your VBA code or simply wished the VBA editor had a Task List window that picked up your Todo comments? The wait is over friends. It’s here.
For the last month Mathieu Guindon and I have been working pretty tirelessly on an open source COM Add-in for the VBA Editor written in C#. Both of us spend a lot of time programming for Office and just got tired of the VBE’s (Visual Basic Editor’s) lack of functionality. As much as Microsoft has tried to move people away from VBA, it doesn’t seem that it is going away any time soon. VBA remains a great solution to many of our Office automation tasks, but the VBA IDE itself has not seen any real changes in over a decade. Even the most popular add-ins haven’t seen an update in a very long time. We all deserve a modernized editor and it’s our goal to bring the VBA IDE into the 21st century.
Today I couldn’t be more excited to tell you that we’ve just released version 1.0 of the software. It’s been a lot of work to get here and we’re just getting started. Without any further ado, it is my honor to present to you…
What’s in Version 1.0?
Boiler-Plate Free Unit Testing
There are a few Unit Testing frameworks out there for VBA. Most of them written in native VBA code and, as a result, they require a lot of boiler plate to function. Tests should be easy to write and run. If they’re not, programmers simply won’t use them. RubberDuck eliminates nearly all of the boilerplate and provides a Test Explorer that lets you decide which tests to run at the click of a button. Mat has truly outdone himself here.
Just add a @TestModule attribute and one line of code. That’s all you need to be ready to start writing your tests.
'@TestModule Private Assert As New Rubberduck.AssertClass
Or alternatively, use the Test Explorer to add a new test module for you.
To write a test, just add the @TestMethod attribute to any public sub in the test module.
'@TestMethod Public Sub OnePlusOneEqualsTwo Assert.AreEqual 2, Add(1,1) End Sub
Refresh the Test Explorer and it will automatically add your new test to the list.
“Todo:” Comments and Task List
Most modern IDEs have some sort of task list that looks at the comments in your projects and adds items with special comments automatically to the list. The VBE is notably lacking this functionality. Rubberduck fills this gap.
Out of the box Rubberduck will pick up comments with the following markers, but it can be configured to pick up any number of custom markers.
'Todo: 'Note: 'Bug:
Double-clicking on any found todo item will jump you to that line of code.
Ever wish you could drill down beyond the module level in the Project Explorer? Now you can with our Code Explorer.
Again, a double-click will jump you to that location in the code.
How can I get Rubberduck?
Unlike a lot of open source projects out there, we’ve created an installer. You can head on over to our releases page and download it. Setup is a breeze. Just a few clicks in the wizard and you’re ready to go.
Alternatively, you can clone the repository and compile the project yourself to get the latest copy. We keep the master branch in a working and buildable state, but there may be incomplete features and possibly a few more bugs than the release version.
How can I contribute?
Anyway you’d like really. Check out the issues page to see if there’s a feature you’re interested in implementing or a bug you’d like to fix. What we really need most right now is people using the add-in to find and submit bugs. I’ve been using Rubberduck for a few weeks now, but the more eyes on, the better. Our wiki and test coverage could use some love too though.
What’s coming in future releases?
Well, we have a lot of things planned, so I’m going to cop out and refer you to the Milestones page. I’m currently working on making Rubberduck easier to customize and configure, but Mat keeps babbling about being ReSharper™ for VBA. There are some very cool things in store and, like I said, we’re just getting started. If you think of a feature you’d like to see added, create a fork and implement it, or submit your request as an issue.
Remember friends, Every Programmer Needs a Rubberduck.