JUnit newbie question

View: New views
1 Messages — Rating Filter:   Alert me  

JUnit newbie question

by durino13 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I have an application, which populates database with data. More specifically, I scan computers in the network for their status (ONLINE, OFFLINE) together with scan failure reasons (HOST_ONLINE, HOST_UNREACHABLE, HOST_NOT_RESOLVABLE, HOST_PORT_CLOSED, etc ..).

I want to test this application using JUnit. I have a 'test' database, which i populate with my custom static data and I execute tests above those data. Everything works ok ..

The problem is, that i find this approach not realible. I insert a computer status in database like ('COMPUTERNAME','ONLINE','HOST_ONLINE') .. This is a valid entry, because it has been inserted manually at the beginning of the test.

However, I want to test also the real data .. E.g. following entry is not allowed ('COMPUTERNAME','ONLINE','HOST_UNREACHABLE') .. Obviously, host can not have a 'status reason' of 'UNREACHABLE', if it is 'ONLINE'.. If for some reason this will occure in my life database, my JUnit tests won't catch this error, because the test database doesn't have such 'invalid' record.

My question: All the JUnit tests use some sort of 'assert' checks. For those
'assert' tests however, I have to have my database in a known state. Having a database filled with 'static test data' won't catch problems I could possibly have in a life database.

What are now the best practices? Do i always have to test both scenarios? Static data + 'life (but still testing) data'? Is this normal?