Unit Testing / TDD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Unit Testing / TDD
Looking to set up unit testing in IDE to assist during development.
Any hints / ideas / suggestions?
(I know there is functional testing in FC testing workbench, but that's not the same thing).
Any hints / ideas / suggestions?
(I know there is functional testing in FC testing workbench, but that's not the same thing).
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Unit Testing / TDD
Nobody? Really?
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Unit Testing / TDD
What constitutes unit testing and why are the current test not considered unit tests? I thought that was what they are called.
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Unit Testing / TDD
You might want to look up Kent Beck, Martin Fowler, Uncle Bob Martin, Ian Cooper, just to name a few. Things have changed a bit since 1995.
Re: Unit Testing / TDD
Here is a video how to do it with QtCreator: https://www.youtube.com/watch?v=N4pvvCToogM
and documentation: https://doc.qt.io/qtcreator/creator-autotest.html
and documentation: https://doc.qt.io/qtcreator/creator-autotest.html
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Unit Testing / TDD
So I ask you about a concept I'm not familiar with and you tell me to go learn about a bunch of dudes instead of the actual subject, weird but okFreddyFreddy wrote: ↑Tue Jun 14, 2022 7:32 am You might want to look up Kent Beck, Martin Fowler, Uncle Bob Martin, Ian Cooper, just to name a few. Things have changed a bit since 1995.
I'm an amateur when it comes to coding and I was born in 1995 so I don't have any old-school bias that you have to dismantle.
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Unit Testing / TDD
No offence intended, but this "bunch of dudes" do a much better job of explaining than I ever could.adrianinsaval wrote: ↑Tue Jun 14, 2022 9:20 pm So I ask you about a concept I'm not familiar with and you tell me to go learn about a bunch of dudes instead of the actual subject
One definition from the dudes is "legacy code is code that does not have tests".
To have useful tests you have to have code broken into clean (SOLID principles etc) manageable chunks.
I am struggling with FreeCAD being largely old code that has not been updated much in the way the "bunch of dudes" would recommend. Huge files (eg 5000 lines) containing multiple classes and behaviours, macros all over the place, language features that have not been updated in many years, etc etc. Quite brittle and hence difficult to work on.
Study the "bunch of dudes" and you'll understand. They have good books, and lots of YouTube.
Re: Unit Testing / TDD
@adrianinsaval I suggest starting with Bob Martin's "Clean Code" - https://www.amazon.com/Clean-Code-Handb ... 132350882/ . It's well-written and lays out the case for this style of development quite nicely.
Anyway, no one is going to disagree that there is significant room for improvement to our codebase, and that any refactoring effort probably needs to begin with making sure we have adequate test coverage of the affected code. What IDE are you working with?
Anyway, no one is going to disagree that there is significant room for improvement to our codebase, and that any refactoring effort probably needs to begin with making sure we have adequate test coverage of the affected code. What IDE are you working with?
-
- Posts: 176
- Joined: Wed Mar 09, 2022 3:15 am
- Location: Oz
Re: Unit Testing / TDD
Not sure if you meant that at @adrianinsaval or me, but anyway, I have been using CLion which is great except it is sloooooow due to inspections, trying qt per Werner's suggestion - having trouble configuring cmake but it is early days.
Re Testing: Not a trivial task as the existing code has to be broken down into units of behaviour. Am more than happy to be involved in discussions as to how that might proceed.
Re: Unit Testing / TDD
On YT there are several videos with Robert C. Martin (aka Uncle Bob) and in the first video it's mainly about clean code. In further videos in this series also the concepts of TDD are explained.