Java Unit Testing Tool with test data in CSV file.
[ 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 n]
2. Go to the performUTByItem() method in the UnitTestManager.java 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() and test_Function_2() as shown in the UnitTestManager.java 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).
assertEqual( UnitTestItem moUTItem, String sActual )
assertEqual( UnitTestItem moUTItem, int nActual )
assertNotEqual( UnitTestItem moUTItem, String sActual )
assertNotEqual( UnitTestItem moUTItem, int nActual )
3. Open the CommonDef.java 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 in the main.java file. A file open dialog or file chooser
appears. Select the CSV file you created for your unit test data.
Ex. Your test data/items are located in the file UT_Test_Sample.csv in D:\Java_Unit_Testing
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.
Input CSV file [unit test data/items] : D:\Java_Unit_Testing\UT_Test_Sample.csv file.
Output CSV file [result or log file] : D:\Java_Unit_Testing\UT_Test_Sample_UT_LOG.csv file.
Please rate this code or project. God bless!
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:
Re-scan downloaded files using your personal virus checker before using it.
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
Terms of Agreement:
By using this code, you agree to the following terms...
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.
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.
You may link to this code from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
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.)