Plannedscape Postings

Image

Autocad Regression Testing
Use A Macro (Or Action Recorder)

Posted by Charlie Recksieck on 2020-07-02
When you add something to a website, are you sure it didn't break something else? When you make changes to an app in your office that has an interface to another app, did that create undiscovered problems? Are you evaluating a new release of key software and not sure what it's going to break? There are all great examples of "regression testing."

Let's use Smartbear's definition of "regression testing": " Regression testing is testing existing software applications to make sure that a change or addition hasn't broken any existing functionality. Its purpose is to catch bugs that may have been accidentally introduced into a new build or release candidate, and to ensure that previously eradicated bugs continue to stay dead. By re-running testing scenarios that were originally scripted when known problems were first fixed, you can make sure that any new changes to an application haven't resulted in a regression or caused components that formerly worked to fail. Such tests can be performed manually on small projects, but in most cases repeating a suite of tests each time an update is made is too time-consuming and complicated to consider, so an automated testing tool is typically required."


Who Is This Article Is For

What follows is a good tip for doing regression testing for AutoCAD. So, it's geared towards our Autodesk friends.

But it's a pretty short article and there are some generic observations about testing, so perhaps it's got educational value for non-AutoCAD folks.


Where Regression Testing Usually Comes Up Short

Like so many other parts about software development, testing is an area that everybody agrees they want to do properly. But like code review, documentation, requirements analyses, etc. it's an area where companies and developers cut corners.

Too often, the developer is testing the code - a big no-no. Or the bug fix or new feature you're working on is getting rushed into production.

If one were to have a good automated way to catch if new code is breaking anything in the system, then one should do it. That's where regression-testing comes in. Apart from AutoCAD and macros which we're about to discuss, please Google "regression testing" tools and start thinking about how they can help you.


AutoCAD Solutions

There are some ways to do regression testing in AutoCAD. Some professional testing services advertise that they work in AutoCAD testing. Autodesk's Revit product has a great "journal" feature to record every action done in a Revit session, but that's not really testing.

And best efforts at regression testing usually involve a list of common functions in a system, environment or company, then when new code is being system tested, whoever is in charge of testing has a checklist of functions to run & see if everything is operating properly.


Macros As An Answer

Thus, what's our magic solution and the whole point of this article? Macros.

What's an AutoCAD "macro", you ask? Basically, it's termed an "Action Recorder", which takes a series of actions you run on an AutoCAD drawing and get to save those actions as a script. You're basically pressing "Record" and doing X, Y and Z on a CAD .dwg, and then asked to save it.

Here's an excellent write up of how to run macros, from the Autodesk blog: https://blogs.autodesk.com/autocad/action-macros-in-autocad.

TIP: Remember that you’ll do this in the "Action Recorder". Technically, behind every Autocad menu command is a "macro" (Google "Autocad menu macros" for how that works).

Now think of the possibilities. In one dedicated test drawing, you can load in all of the standard and customized routines that you run into a macro, save it. Then as part of your routine testing, you'll open your testing DWG, run the macro and see what, if anything, breaks.


Case Study

For years we've specialized in custom code solutions for electric utility companies running on top of AutoCAD. We used to have to manually system test everything when we'd write some new code.

Now that we've developed a test DWG with one big macro of all of our features, we can do much better regression testing than we ever did before by clicking play on our test macro. While it's running, it's a great time to grab a snack or take a bathroom break. When we get back to the computer, any error would be on the screen; or if no errors, we'd see that everything finished fine and be able to trace everything through the command prompts of all functions called.


What To Load In A Testing Macro

As we just said, feel free to make your testing macro huge. You can make one macro to test every conceivable thing you'd want in your regression testing. In fact, we recommend it.

Meanwhile, any testing document (not just regression testing) should not only list what your testing but your expected result. And you should also be testing for scenarios that should fail in addition to just what you want to work. All of your fail scenarios should be well handled without end users seeing an ugly error message or, worse, yet, a crash.


The Takeaway

This isn't groundbreaking stuff. This could have been a one-sentence post: "Use macros to regression test in AutoCAD."

But in preparation, we Googled "regression testing" and "autocad" and did not see much at all about this. So, maybe it's a novel idea. Give it a try if you work in AutoCAD. And if you do - we'd love to hear about your results!