vendredi 12 juin 2020

How to orginaze unit test in Java?

In my program is two classes: Main.java and DatabaseConnector.java. The second includes 10 methods (making/closing connection, interpreting args values and methods that interacts with database by PrepareStatement).

For each function I want to write about 2-4 test. My question is how to organize that? Should I create DatabaseConnetorTest class and there include all 20-40 tests? Or it is good to make new test class for each function (makeConnectionTest, InsertOrderTest, ...) for better code transparency?

Another question is, what is a good practice to test function that interacting with mysql database?

Aucun commentaire:

Enregistrer un commentaire