FreeCAD_SheetMetal
FreeCAD_SheetMetal copied to clipboard
Unit Tests to catch regressions introduced in development (either in master or in this repo)
Can we discuss a way to run some unittests that catch possible regressions in this awesome addon. Case in point: https://forum.freecadweb.org/viewtopic.php?f=3&t=11303&p=361751#p361751
I guess I should open a ticket in FreeCAD-addons requesting a tutorial on how to write a unit test and ask Addon authors/FC-community to do so for addons.
addon unit test tutorial: +1
Absolutely necessary. #122 wouldn't exist if there were appropriate unit tests.
Moreover, unit tests would greatly help cleaning up the existing code. I would terrify if I start some cleanup because there is always a possibility to mess up the serious calculations.
Ping @luzpaz
Is there any clear instructions about writing unit tests?
@ceremcem not that I know of off hand, sorry. Hope someone wrote some documentation for it. But if not, then it would be old-fashion look at the pre-exisiting unit-tests in the core workbenches for orientation + asking on the forum
I would like to start with defining how it should be (according to me, of course):
- Start recording a macro.
- Create a part from scratch or load it from a file.
- Perform relevant operations.
- Stop the macro recording.
- Create a Spreadsheet named
Teststhat will hold the expected values (lengths, angles etc.). It should contain "Description" (optional), "Expected" and "Observed" columns.Expectedcolumn should be hard coded andObservedcolumn will be calculated by a formula. - Use another macro, named "Test.FCMacro", which will simply "Compare the
ExpectedandObservedcolumn values in theTestsSpreadsheet.
This is how I expect to create a test for any workbench.
In order to execute tests:
- Execute FreeCAD by passing the relevant macro (and supply the file if a file is used) and the
Test.FCMacroas arguments. I expect FreeCAD to execute first macro, recreate the values, and then executeTest.FCMacro, return the output ofTest.FCMacro.
How does it sound?