How to test different "tables input" in Java?

Viewed 176

I have a Java program that retrieves data from 2 tables and after a quick processing, stores the resulting data in 2 other tables.

Therefore, I need to test the global behavior of my code, so the first idea that came to my mind is to create a lot of small input tables, with 2 or 3 rows (just for the test) . And then perform the code throughout all these test-tables and compare with the expected results (which are also small tables created beforehand). the problem is that I don't know how to proceed

2 Answers

Your initial idea would overcomplicate things. I would just create exact copies of the tables with a _test suffix and perform the same operations for the test tables as I would perform for the real tables. After the operations are completed, compare the contents of your test tables content with your expectations and then empty them.

Assuming that your tables are called s1, s2 and d1, d2, respectively, let's create s1_test, s2_test, d1_test and d2_test for your tests. And then perform the following algorithm:

for tc of testcases
    initialize s1_test, s2_test
    perform tc.operations(s1_test, s2_test, d1_test, d2_test)
    compare contents of d1_test and d2_test with tc.expectations
    clear d1_test, d2_test
end for
Related