Changes between Version 21 and Version 22 of Projects/GSoC/TestingReview/CMock


Ignore:
Timestamp:
07/08/12 20:14:21 (12 years ago)
Author:
Xiaochen Pan
Comment:

/* Host-based Test Result */

Legend:

Unmodified
Added
Removed
Modified
  • Projects/GSoC/TestingReview/CMock

    v21 v22  
    6262= Host-based Test Result =
    6363
     64== Unity Output ==
     65
    6466''This is the test case''
    6567
     
    7678From the above, it can be seen that it reports single assert failures as well as test case running result. In the above screenshot, the line 2011 assert fails, and that test case passes with the macro VERIFY_FAILS_END at the end.
    7779The test summary shows that all 174 test cases have passed.
     80
     81In addition, with the ruby script, it can be seen that very large number of 174 test cases can be automated.
     82== CMock Output ==
     83
     84''This compilation option in ruby script says that the total amount of memory can be used in tests is 32000 byte.''
     85    prefix: '-D'
     86    items:
     87      - __monitor
     88      - CMOCK_MEM_STATIC
     89      - CMOCK_MEM_SIZE = 32000
     90
     91
     92
     93''The is the test case with mocking functions:''
     94    void testMainShouldCallExecutorInitAndContinueToCallExecutorRunUntilHalted(void)
     95    {
     96          Executor_Init_Expect();
     97          Executor_Run_ExpectAndReturn(TRUE);
     98          Executor_Run_ExpectAndReturn(TRUE);
     99          Executor_Run_ExpectAndReturn(TRUE);
     100          Executor_Run_ExpectAndReturn(TRUE);
     101          Executor_Run_ExpectAndReturn(FALSE);
     102 
     103          AppMain();
     104    }
     105
     106''In the above code, Executor_Init function is being mocked and expected to execute once in the AppMain() function. Executor_Run function is being mock with two different modes and is expected to run five times, with the top four times to return true and the fifth time to return false.''
     107
     108"This is the test result output:''
     109
     110  Creating mock for Executor...
     111  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ ../vendor/unity/src/unity.c -obuild/unity.o
     112  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ mocks/MockExecutor.c -obuild/MockExecutor.o
     113  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ src/Main.c -obuild/Main.o
     114  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ ../src/cmock.c -obuild/cmock.o
     115  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ build/TestMain_Runner.c -obuild/TestMain_Runner.o
     116  gcc -D__monitor -DCMOCK_MEM_STATIC -D"CMOCK_MEM_SIZE = 32000" -DTEST -c -Isrc/ -I../src/ -I../vendor/unity/src/ -I../vendor/unity/examples/helper/ -Imocks/ -Itest/ test/TestMain.c -obuild/TestMain.o
     117  gcc -lm build/unity.o build/MockExecutor.o build/Main.o build/cmock.o build/TestMain_Runner.o build/TestMain.o -o build/TestMain.exe
     118  build/TestMain.exe
     119  test/TestMain.c:14:testMainShouldCallExecutorInitAndContinueToCallExecutorRunUntilHalted:PASS
     120  -----------------------
     121  1 Tests 0 Failures 0 Ignored
     122  OK
     123
     124It can be seen from the above process that mocking functions are created automatically according to the specification of mocking behaviors stated in the above code. The test case testMainShouldCallExecutorInitAndContinueToCallExecutorRunUntilHalted has passed.