Unit Test Conundrum

I am looking for unit testing as a means of regression testing a project.

However, my problem is that the project is mainly an illustrious DIR team - it performs regular expression tests and MD5 filters according to the results and allows you to specify many criteria, but all this is designed to process input from the system on which it is executed .

I am also a development team, and I doubt the value of the test for the code I wrote, which I wrote.

Is unit testing worthwhile in this situation? If so, how can such tests be carried out?

EDIT: MD5 and Regex functions are not provided by me - they are provided by the Crypto ++ and Boost library, respectively. Therefore, I do not get much experience testing them. Most of the code that I just upload to the libraries prints the results.

+4
source share
8 answers

In this case, is it worth testing the device?

Optional: especially for a one-person team. I think this may be enough to automate testing of something more than a "unit" ... more on the page Should I test the internal implementation or test only social behavior? "

+3
source

The value of test-after, as you ask, can indeed be limited in certain circumstances, but the path to unit test from the description will be to isolate the regular expression tests and MD5 filters in one section of the code and abstract the input signal, so that during the production process, it comes from the system, and during the unit test, your test class passes in this input.

Then you collect a sample of the various scripts that you intend to support, and feed them using the various unit tests that each script runs.

I think the unit test value will happen if you have to change the code to handle new scripts. You will be sure that old scripts will not break when changes are made.

+4
source

Unit testing can still provide value in a one-person show. This gives you confidence in the functionality and correctness (at some level) of the module. But some design considerations may be required to make testing more applicable to your code. Modulation makes a big difference, especially if it is combined with some kind of dependency injection, instead of a tight connection. This allows the use of test versions of co-authors for testing an isolated module. In your case, the mock file system object can return a predictable data set, so your filtering code and criteria can be evaluated.

+1
source

The value of regression testing is often not realized until it is automated. After that, everything will become much easier.

This means that you should be able to start from a known position (if you create MD5 on files, you must start from the same files every time). Then get one successful run in which you can save the result - this is the basic level.

From now on, regression testing is just a button task. Start your test, collect the result and compare it with a known base (of course, if the output will ever change, you will need to check it manually or using another independent script before saving it as a new baseline).

Remember that the idea of โ€‹โ€‹regression testing is to catch any errors introduced by the new code (i.e., regress the software). This does not test the functionality of this new code.

The more you can automate this, the better, even as a one-person development team.

+1
source

When you wrote the code, did you test it when you sent it? These tests can be written to an automated script, so when you need to make changes after 2 months, you can re-run all these tests to make sure that you have not canceled anything.

In my experience, the probability of regression increases dramatically depending on how much time has passed since you finish version 1 and start coding version 2, because you will usually forget the subtle nuances of how it works in different conditions - your unit tests is a way to encode these nuances.

0
source

A file system integration test would be helpful. Just make sure that he does what he needs.

0
source
  • Is unit testing valuable in a one-person scenario? Absolutely! There is nothing better than the ability to reorganize your code with the absolute certainty that you have not broken anything.

  • How can I unit test this? Refuse system calls and then check the rest of your logic.

0
source

I doubt the value of the test for the code I wrote, which I wrote

Well, it's true now, but in a year you will be, one year old, a more experienced developer, developing against the software you wrote - now a less experienced and knowledgeable developer (for comparison). Don't you want the code written by this less experienced guy (a year ago) to be properly checked so that you can make changes with confidence that nothing has broken?

0
source

All Articles