Felix Zumstein gave a presentation on automated testing of Excel workbooks at an xlwings Meetup in NYC. The presentation covered writing unit tests for VBA functions and cell formulas using xlwings in Python, running integration and logic tests on workbooks, comparing implementations to tested libraries, and setting up continuous integration to run the tests automatically after code changes. Examples were given of different types of tests like VBA unit tests, cell formula tests, and integration tests involving macros. Unittest and other test frameworks were also discussed for running the tests.
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Automated testing of Excel Workbooks
1. Automated Testing of
Excel Workbooks
Felix Zumstein, Oct 3rd, 2019
xlwings Meetup NYC
From unit tests to continuous integration
2. Agenda
2
1. Meetup organisation
2. xlwings intro
3. Automated testing by Felix Zumstein
4. Teaching machine learning via xlwings
by Daniel Guetta, Senior Lecturer at Columbia
Business School
7. • Local Git extension that makes git diff and
git merge work with VBA code (only)
• Free & open-source
Git XL
7
8. xlwings CI
8
Continuous integration for Excel files
• Write unit tests for Excel files with xlwings
• Run them automatically on the server after
pushing changes to your Git repo
Example: Gitlab Pipeline
11. Meetup organisation
11
• Community event
• About any innovative solution for Excel,
not just those based on xlwings
• Contact me if you want to give a talk
(short or long) in one of the next
meetups
15. What is a unit test (Python sample)?
15
Python function that
we want to test
Unit test:
OK or FAIL
16. Map VBA functions to Python
16
VBA function
my_sum (Python)
MySum (VBA)
args result
17. VBA unit test boilerplate
17
run at the
beginning and
end of the test
suite, respectively
actual test
18. What can be tested in Excel?
18
1) Unit test: E.g. a cell formula, a VBA function
2) Integration test: E.g. running a macro or
testing the effect of a cell change on the
whole workbook
3) Cell logic test: Test dynamic tables
4)Alternative implementation test: Comparison
with a function from (a tested) 3rd party lib
26. Continuous integration (1/2)
26
• Write unit tests for Excel files with xlwings
• Run them automatically on the server after
pushing changes to your Git repo
Example: Gitlab Pipeline