unit_tests
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
unit_tests [2016/09/08 17:35] – [Coding the unit tests] mhatz | unit_tests [2016/09/08 17:43] – [HOWTO writing a unit test for a class] mhatz | ||
---|---|---|---|
Line 5: | Line 5: | ||
For Mail2Voice Next, we introduced unit tests. Units tests are useful to ensure that every classes/ | For Mail2Voice Next, we introduced unit tests. Units tests are useful to ensure that every classes/ | ||
- | The unit tests written for Mail2Voice are base on QTest suite. | + | The unit tests written for Mail2Voice are based on QTest suite. |
- | ===== HOWTO : writing a unit test for a class ===== | + | ===== HOWTO writing a unit test for a class ===== |
- | Each class of Mail2Voice must have its dedicated unit tests to check every method | + | Each class of Mail2Voice must have its dedicated unit tests to check every methods |
==== Example ==== | ==== Example ==== | ||
Line 160: | Line 160: | ||
+ | Then, in the main.cpp file of the unittests subproject, you have to instantiate a TestMyClass object and add it to the list of tests to run: | ||
+ | <code cpp> | ||
+ | int main( int argc, char *argv[]) | ||
+ | { | ||
+ | int ret = 0; | ||
+ | |||
+ | TestContact tstContact; | ||
+ | TestEmail tstEmail; | ||
+ | TestAccount tstAccount; | ||
+ | TestAttachment tstAttachment; | ||
+ | TestServerSettings tstServerSettings; | ||
+ | TestMyClass tstMyClass; // <-- instantiation | ||
+ | |||
+ | ret = executeTests(argc, | ||
+ | {& | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | & | ||
+ | |||
+ | return ret; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Running unit tests ==== | ||
+ | Well, that is the simplest part, just select the unittests subproject in QtCreator, compile it and run it! |
unit_tests.txt · Last modified: 2023/04/25 16:52 by 127.0.0.1