How to organize data integrity tests and code tests?

I have several files with code testing code (which uses the unittest class).

Later, I discovered that it would be nice to test the integrity of the database. I put this in a separate directory tree. (Things like keys have the correct format, the parent and child nodes are pointing correctly, etc. Editing: this is a nosql project where I cannot rely on checking the level of the liek referential integrity database, etc.)

I use the same unittest class for integrity tests.

Now I wonder if it makes sense to keep it separate. To verify data integrity, I often duplicate parts of the code that I use to validate code that processes data.

But this is not the same. Code tests use test databases (which are deleted after each test), and integrity tests connect to the current data and analyze them. Integrity tests, which I want to call from cron, and send an alarm if something happens in a live database.

How would you handle this? Are there standards for such an installation? What is your experience?

My tendency is to put everything in the same file, which will lead to code tests also running cron in the production environment.

Edit: what also forces me to try to keep the project simple and not have too many files affected by one task or workflow. Without any testing, I already have a class file, a subclass, an associated class, some library (auxiliary) files, and the main code. Testing adds one file. This helps me focus on coding, but it is less, and I believe that I make fewer mistakes, and I can quickly remember and find a certain part of the code with fewer affected files. Only one test file per workflow can help here. If I save it separately, there are 2 files (data integrity testing and code testing) and possibly 3 (a common library for both). Abstraction will add complexity.

Edit2: , , , "" "". () , 2 , . .

Edit3: , . , 2 "" " ", directury.

, . , !

Edit4: . , 2 , . . . . ( ) ( , ). : , . , , . . , , obejct, .

, "user89021", , karlthorwald. .

+5
3

, , "" .
, - , , , , ( , ).

, ( ), .

, /, . , ( ), , .

+4

.

100% .

- - , "RunTest", "AnalyzeResult", "ConnectToDB" - ( , , , ), , , .

unit test, , , , (, , ).

, , /

+4

. . , , - . , . IOW, .

, , . , ?

. , , .

, .

0

All Articles