Important alert: (current site time 5/22/2013 10:24:29 AM EDT)
 

winzip icon

C Unit Testing Tool with test data/items in CSV file

Email
Submitted on: 8/10/2012 1:39:40 PM
By: Victor Rocales 
Level: Intermediate
User Rating: Unrated
Compatibility: C
Views: 1062
author picture
 
     C Unit Testing Tool with test data/items in CSV file. (Linux Platform) [ Background of this project or tool ] This project or tool performs a unit testing on a specified method or methods. You can test as many methods as you can. You can create a test driver for testing a function/method with test data for the function/method parameters coming from a CSV file. You can test a single function/method ten times or even a hundred times depending on the no. of your test data/items you created in the CSV file source. This eliminates the need for creating a single test driver for every test data or item. In this code a single test driver/function can run or test multiple test data/items. [ How to use this project or tool? ] 1. Create a unit test data/items in any CSV file as shown in the example file "UT_Test_Sample.csv". The file is of "*.csv" format. The test data or test items are comma separated. The format for the test items is shown below. Unit Test item format : [function name][expected result][no. of parameters (nth)][parameter 1][parameter 2] up to [parameter (nth)] 2. Go to the performUTByItem() method in the UnitTestMgr.c file and modify it to run and link your test code drivers. Examples of test driver functions/methods are shown below. Ex. test_Function_1() up to test_Function_12() as shown in the UnitTestMgr.h and UnitTestMgr.c file. You can change the name of your test driver functions/methods to any name you want. In test driver function/method you can use the functions/methods listed below to compare the actual result from your expected result as placed in your unit test items/data (in the CSV file). void assertEqualCh( Text_pMap pUTItemMap, TCHAR chActual ); void assertEqualInt( Text_pMap pUTItemMap, int nActual ); void assertNotEqualCh( Text_pMap pUTItemMap, TCHAR chActual ); void assertNotEqualInt( Text_pMap pUTItemMap, int nActual ); 3. Open the CommonDef.h file and modify it to link your test function drivers. The function/method you want to test should be link in this file. The function/method names should be found in your test code data/items ( in the CSV file ). 4. Run the main function/method "int main(void)" in the C_UnitTestingTool.c file. Ex. Your test data/items are located in the file UT_Test_Items.csv in D:\Java_Unit_Testing folder or any other folder. After openning and running the unit testing process, the application will create and/or logged the results in the file UT_Test_Sample_UT_LOG.csv file. The program will append "UT_LOG.csv" to the file name of your unit test data CSV file. Ex. Input CSV file [unit test data/items] : D:\C_Unit_Testing\UT_Test_Sample.csv file. Output CSV file [result or log file] : D:\C_Unit_Testing\UT_Test_Sample_UT_LOG.csv file. Please rate this code or project. God bless! Truly yours, Victor Rocales vicrocs@yahoo.com

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.