Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Test Connundrum

Tags:

unit-testing

I'm looking to unit testing as a means of regression testing on a project.

However, my issue is that the project is basically a glorified DIR command -- it performs regular expression tests and MD5 filters on the results, and allows many criteria to be specified, but the entire thing is designed to process input from the system on which it runs.

I'm also a one-man development team, and I question the value of a test for code written by me which is written by me.

Is unit testing worthwhile in this situation? If so, how might such tests be accomplished?

EDIT: MD5 and Regex functions aren't provided by me -- they are provided by the Crypto++ library and Boost, respectively. Therefore I don't gain much by testing them. Most of the code I have simply feeds data into the libraries, and the prints out the results.

like image 204
Billy ONeal Avatar asked Jan 24 '23 14:01

Billy ONeal


2 Answers

The value of test-after, the way you are asking, can indeed be limited in certain circumstances, but the way to unit test, from the description would be to isolate the regular expression tests and MD5 filters into one section of code, and abstract the feeding of the input so that in production it feeds from the system, and during the unit test, your test class passes in that input.

You then collect a sampling of the different scenarios you intend to support, and feed those in via different unit tests that exercise each scenario.

I think the value of the unit test will come through if you have to change the code to handle new scenarios. You will be confident that the old scenarios don't break as you make changes.

like image 194
Yishai Avatar answered Feb 01 '23 07:02

Yishai


Is unit testing worthwhile in this situation?

Not necessarily: especially for a one-man team I think it may be sufficient to have automated testing of something larger than a "unit" ... further details at "Should one test internal implementation, or only test public behaviour?"

like image 44
ChrisW Avatar answered Feb 01 '23 09:02

ChrisW