Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans cunit tests cases never end

Trying to test my C project on NetBeans, the tests never end while the output is:

   Test: testFileOne ...passed   Test: testFileTwo ...passed

 Run Summary:    Type  Total    Ran Passed Failed Inactive
               suites      1      1    n/a      0        0
                tests      2      2      2      0        0
              asserts      8      8      8      0      n/a

 Elapsed time =    0.000 seconds

Even if it seems complete, the progress bar is still shining at the value 0.0%.

Test cases are all like:

void testMethod() {
     CU_ASSERT(1 == 1);
     //other lines of code..
     CU_ASSERT(0 == 0);
 }

with more than one CU_ASSERT for each function. Some behaviour with auto-generated test code by NetBeans.

The command

make test

from command line works like a charme and ends with no problem.

Anybody has encountered this issue before? any way to get it solved without strambling my laptop? Thank you in advance for every comment.

like image 296
Desmond Avatar asked Nov 04 '22 09:11

Desmond


2 Answers

You can use a debugger (e.g gdb) to trace what happens.

This will require debugging flags to be added to your cunit code. Assuming you're using gcc, this will be the -g flag.

After compiling with debugging flags you can simply start the test binary with with the debugger, the way you'd debug a normal program.

like image 84
Ishay Peled Avatar answered Nov 09 '22 13:11

Ishay Peled


It seems that Netbeans requires a certain directive a to stop the Test Suite and this is exactly printf("%%SUITE_FINISHED%% time=0\n");. Here is how your test should look like (either you are using plain vanilla C or some library like CUnit):

#include <stdio.h>
#include <stdlib.h>

void test1() {
    // do your stuff
}

int main(int argc, char** argv) {
    printf("%%SUITE_STARTING%% mysimpletest\n");
    printf("%%SUITE_STARTED%%\n");

    printf("%%TEST_STARTED%% test1 (mysimpletest)\n");
    test1();
    printf("%%TEST_FINISHED%% time=0 test1 (mysimpletest) \n");

    printf("%%SUITE_FINISHED%% time=0\n");

    return (EXIT_SUCCESS);
}
like image 43
Pantelis Sopasakis Avatar answered Nov 09 '22 14:11

Pantelis Sopasakis