AutoTest / QtTest: Any experience here?
Really looking for a good guide how to use QtTest.
How do I use my orignal quick2 application code (start with c++ code) from within the unit test application?
I have a "Qt Quick 2 Controls Application" project and just now I've created a Auto Test Project using QtTest.
I opened my non-test project so the are both at top level in projects and in my test project under Project, Dependencies I've selected my application project.
This is all guesswork and the only test material I seem to find is just for standalone tests of math logic... well that's great if my entire project was to release a test project only... I have to ship a real working project.
I cannot figure out how to reference my application classes? Just pretty lost and using lots of time. Also using a lot of time now I've got quite a bit going on... I'd like to really put my code through it's paces, logic tests first and maybe even performance tests/metrics. Help?
@6thC Usually in unit tests you just reference the source code files you want to test (in test PRO file):
SOURCES += ../src/my_source_file.cpp HEADERS += ../src/my_source_file.h
Hey, thanks. So doing this your way is really just referencing the actual source code / physical file from my real project hey? I was kinda hoping not to have to move everything into a library for this, this feels like good enough for me to get started at least writing and executing some tests... thanks.
I also just found this: https://www.youtube.com/watch?v=nXokfmz7j18 - which demonstrated moving existing code into a library and using that from both projects.
I think I'll start with yours, ta. I didn't realize I could just navigate down and up again and it all be ok. But that relationship with my app and testapp is exactly what I do want where I operate the tests on the current code. Thanks again.
move everything into a library
Why do you think you need to move everything into a library?!
There is no need for a library.
You just use your source code files in your test projects.
Unit tests usually just include parts of the code files which are tested.
Lets say you want to write a unit test for file_1.cpp and file_2.cpp which are part of your exe project. Then just create a unit test project and reference those files there - they will be compiled into the unit test executable.
I was just mentioning that's how the video demonstrated.
Thanks to you I have the files in my test project and they are the files from my actual app, now
compiling seems to be the issue.
I had a couple things to do to get it build able again but now I can at least compile my c++ classes. I have one test with one of my objects now so thanks.