Using Catch2 UT framework for app testing

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Using Catch2 UT framework for app testing

Post by Widgets »

Although I have used some unit tests with cppUnit before, I just came across Catch2 and the test samples in the wxWidgets source tree.
After reading the recommended how-to-write-unit-tests.md, and compiling and running the GUI test sample, I still have some very basic questions about how I would go about building my own test - for both GUI & non-GUI functionality.
The .md file only covers things in a very general way and, while I could start with a copy of the test_gui sample and start stripping it down to one of the Catch2 enabled projects, I am hoping someone's experience & comments can save me a lot of time.

Perhaps I should ask in a different part of this forum? If so, please let me know & I'll move my question.
FWIW, running the GUI test samples seems to run to completion only sometimes & only after hanging several times and when it does complete, it shows a long list of memory leaks.
These consideration make me ask before I plunge in and ..... :-)

And a very happy new year to all
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using Catch2 UT framework for app testing

Post by ONEEYEMAN »

Hi,
Widgets wrote: Wed Jan 01, 2020 12:04 am Although I have used some unit tests with cppUnit before, I just came across Catch2 and the test samples in the wxWidgets source tree.
After reading the recommended how-to-write-unit-tests.md, and compiling and running the GUI test sample, I still have some very basic questions about how I would go about building my own test - for both GUI & non-GUI functionality.
The .md file only covers things in a very general way and, while I could start with a copy of the test_gui sample and start stripping it down to one of the Catch2 enabled projects, I am hoping someone's experience & comments can save me a lot of time.
The best way to start something with wxWidgets is to copy the appropriate sample folder, strip it and then add your own code.
I would guess that it is the same in your case.
Widgets wrote: Wed Jan 01, 2020 12:04 am Perhaps I should ask in a different part of this forum? If so, please let me know & I'll move my question.
FWIW, running the GUI test samples seems to run to completion only sometimes & only after hanging several times and when it does complete, it shows a long list of memory leaks.
These consideration make me ask before I plunge in and ..... :-)
Well, does it finish without any assertions or crash? This is the most important when running the unit test.
Also, it would be ice to know:
1. Platform/version
2. wx version
3. Compiler/version.
Widgets wrote: Wed Jan 01, 2020 12:04 am And a very happy new year to all
Same to you.

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Using Catch2 UT framework for app testing

Post by Widgets »

ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm The best way to start something with wxWidgets is to copy the appropriate sample folder, strip it and then add your own code.
I would guess that it is the same in your case.
Well, the 'test' tree is quite large, but if that is the only way .....
ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm Well, does it finish without any assertions or crash? This is the most important when running the unit test.
As I mentioned, it hangs - no crash as far as I can tell, but I had to kill it and next time it may run to completion or or it may hang again ... something like about 5 -6 cycles, before it completes without a hang after a restart.
Makes me wonder about uninitialized variables, but when I try to interrupt a hang it is so far down the hole that backtracking is too frustrating, especcially until I understand the expected program flow better.
ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm Also, it would be ice to know:
1. Platform/version
2. wx version
3. Compiler/version.
My apologies.
Win 10, MSVC 2019 Community, wxWidgets 3.1.2
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using Catch2 UT framework for app testing

Post by ONEEYEMAN »

Hi,
Widgets wrote: Thu Jan 02, 2020 3:59 pm
ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm The best way to start something with wxWidgets is to copy the appropriate sample folder, strip it and then add your own code.
I would guess that it is the same in your case.
Well, the 'test' tree is quite large, but if that is the only way .....
No, its not the only way, but its the best way. Creating wx project from scratch is complicated.
Widgets wrote: Thu Jan 02, 2020 3:59 pm
ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm Well, does it finish without any assertions or crash? This is the most important when running the unit test.
As I mentioned, it hangs - no crash as far as I can tell, but I had to kill it and next time it may run to completion or or it may hang again ... something like about 5 -6 cycles, before it completes without a hang after a restart.
Makes me wonder about uninitialized variables, but when I try to interrupt a hang it is so far down the hole that backtracking is too frustrating, especcially until I understand the expected program flow better.
Did you build the library itself?
Did you open the wxWidgets\build\msw\wx_vc15.sln and do: "Build->Batch Build->Build ALL"?
Also, at which point does it hangs? Can you post the log from the screen?
Widgets wrote: Thu Jan 02, 2020 3:59 pm
ONEEYEMAN wrote: Thu Jan 02, 2020 3:20 pm Also, it would be ice to know:
1. Platform/version
2. wx version
3. Compiler/version.
My apologies.
Win 10, MSVC 2019 Community, wxWidgets 3.1.2
Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Using Catch2 UT framework for app testing

Post by Widgets »

What I have done:
Download the wxWidgets 3.1.2 package for Windows
Install it all and build my libraries - mainly for statically linked 32-bit apps.
Root for the wxWidgets 3.1.2 tree: D:\MSVC2019\wxWidgets-3.1.2\
Cd to the directory D:\MSVC2019\wxWidgets-3.1.2\tests
Open the .sln file test_gui_vc15.sln
and let MSVC compile the whole works
then run the debug version of test_gui
The test frame window is hidden behind the console window.
Moving the console window to show the test frame seems to sometimes help.
It almost seems as though the tests are waiting for some user input, because it seems tapping the 'Enter' key allows things to move forward, at least some times.
If you look at the test solution under windows, you will see an awful lot of code, and most of it is still using CppUnit style so it is not at all obvious (at least to me) which parts are essential and which relate only to specific projects/tests.
Quite possibly, the UT code includes its own copies of wxWidgets support libs.
But as I have not heard anything else specific, starting with a copy will likely be my next step ... once I finish the bulk of the work which prompted me to look at UT again
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using Catch2 UT framework for app testing

Post by ONEEYEMAN »

Hi,
Yes, moving from crrpunit to catch is not yet complete.

It would be nice to see where the UT is holding and why it is not going...

Thank you.
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Using Catch2 UT framework for app testing

Post by Widgets »

Eventually I will get there and report back.
But right now, getting things at least sort-of-working will take precedence :wink:
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Widgets
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Using Catch2 UT framework for app testing

Post by Widgets »

My latest tests using the latest code for wxWidgets from Github show no problems with hanging at all.
The 32-bit debug version compiled & ran to completion without a hitch.
It still shows piles of memory leak though.
As well, a very cursory check shows that a lot more of the test have been ported to Catch2; never did an exhaustive check, though for completeness.
Environment: Win 10/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply