tags:

views:

85

answers:

1

Suppose I have an arrayOf Object having some values returned from the database. I want to check whether any one of the array object does not contain any value, how can it be done using Junit 4.

Can I write any customized test case in Junit4?

+1  A: 

Sure, JUnit4 is a unit testing framework - it was created to allow rapid testing of small pieces of functionality.

So a simple example will look like this:

class MyTesterClass {
    @Test
    public void checkAllObjectsHaveValue() {
        String[] data = DAO.findAllData();
        for(String s : data) 
            assertFalse( s.isEmpty() );
    }
}

You can create a number of such classes, and each can have more than one method. Once you have them, they can be ran automatically or manually, using your IDE, ant, maven or other build tool you use. It will report failure or success based on the condition you provided in assert* statements.

Gregory Mostizky