Unit Testing (1 Viewer)

GBalcom

Much to learn!
Local time
Yesterday, 17:27
Joined
Jun 7, 2012
Messages
459
Does anyone do unit testing on their VBA projects within Access? I use RubberDuck, which has a framework for it, but I'm having a hard time understanding what and how I would actually test, and perhaps more important, if it's truly worth it.
 

isladogs

MVP / VIP
Local time
Today, 01:27
Joined
Jan 14, 2017
Messages
18,209
Rubber duck caused a lot of crashes on the two workstations I installed it on.
I never managed to use it for anything useful and uninstalled it again
 

sonic8

AWF VIP
Local time
Today, 02:27
Joined
Oct 27, 2015
Messages
998
Does anyone do unit testing on their VBA projects within Access? I use RubberDuck, which has a framework for it, but I'm having a hard time understanding what and how I would actually test, and perhaps more important, if it's truly worth it.
Yes, I do Unit Testing in my Access/VBA-Projects. I use my own, personal customization of the accessUnit testing framework. - I will probably do a major rewrite of my customizations very soon and then publish them.


Now, Unit Testing and VBA/Access are a bit of a difficult combination. Two things that are hard to test automatically are the user interface and databases. Access excels at gluing database objects right to the user interface and thus creates untestable clusters.


What you can (unit) test very well are classes and functions which are not tied directly to neither the database nor the user interface.


Is it worth it? - Yes! Absolutely!


Just earlier today I had to fix a bug with a rare edge case in a function. My two first approaches fixed the bug but broke the function in some other use cases of the function. Luckily I had 10 existing test cases for that function covering all other scenarios. These test cases revealed the newly introduced errors in milliseconds. I would have never remembered all other 10 different use cases to test them manually. Even if I had, figuring out their parameters and the correct return values to test them manually would have probably taken longer than writing all of the test cases while I had each of them fresh in my memory.


Another benefit:

When writing tests first (TDD), you will write your code in a way that it is easy to test. - You'll most likely discover after a while that this type of code turns out to also be much more readable, reusable, maintainable, and adaptable.
 

Users who are viewing this thread

Top Bottom