0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Check Theories and Parameterized. Those are jUnit (experimental) implementations of parameterized tests that seem to be a good fit for your case.

Comments