Page 1 of 1

Using Catch2 UT framework for app testing

Posted: Wed Jan 01, 2020 12:04 am
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

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 3:20 pm
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.

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 3:59 pm
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

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 4:13 pm
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.

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 5:12 pm
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

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 8:49 pm
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.

Re: Using Catch2 UT framework for app testing

Posted: Thu Jan 02, 2020 9:51 pm
by Widgets
Eventually I will get there and report back.
But right now, getting things at least sort-of-working will take precedence :wink:

Re: Using Catch2 UT framework for app testing

Posted: Sat Jan 04, 2020 3:41 am
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.